WordPress 7.1 hardens REST attachment handling when stored filesize metadata is not an integer. A production fleet may contain numeric strings, decimals, nulls, arrays, corrupted serialized values, missing local files, offloaded objects, and optimizer-specific fields across many sites. A blind normalization script can erase evidence or write invented sizes.
Use this for agencies, multisite networks, migrations, restores, media offload systems, image optimizers, DAM integrations, and sites that expose media through the REST API or block editor.
Quick answer
Run a read-only fleet inventory first. For each site and sampled attachment, record WordPress version, site ID, attachment ID, MIME type, metadata parse state, filesize value and type, local path state, remote object state, actual known bytes, last modified time, suspected writer, REST collection result, REST detail result, and editor impact. Group identical signatures and correlate them with plugin versions, migration windows, and storage providers. Reproduce one signature on staging, repair only records with a known authoritative byte count, write in small reversible batches, and watch for the bad type to return so the original writer can be fixed.
Test scenarios to run
Run the same controlled fixture across these branches. Write down the expected result before testing so a surprising response is easy to identify.
| Scenario | Fixture | Expected result |
| Numeric string | Known local file | Classify and verify REST |
| Array | Writer unknown | Preserve and investigate |
| Remote-only | Object bytes known | No invented local file |
| Repair batch | 100 known IDs | Export and reconcile |
Diagnostic table
Use this table to connect the observed behavior to evidence and a verification step.
| Action | Evidence | Verification |
| Run a read-only fleet inventory | Inventory site ID, WordPress and PHP versions, storage mode, optimizer, migration tool, attachment count, REST consumers, cache layers, and the approved read-only query. | Every affected record is classified by site, attachment, type, and source state. |
| Cluster malformed signatures | Classify metadata as valid integer, numeric string, decimal, blank, null, array, corrupt serialization, missing key, local missing, remote-only, or size mismatch. | REST and editor paths remain valid for all fixture classes. |
| Identify authoritative size and writer | Sample REST collection, detail, edit context, search, pagination, media modal, featured image, and block-editor requests for each signature without logging private filenames publicly. | Repaired IDs reconcile with authoritative local or remote bytes. |
| Repair reversible known batches | Correlate first-seen time and site clusters with plugin deployments, imports, restores, offload jobs, optimizer runs, and custom metadata writers. | The same bad signature does not return after the writing job runs. |
What to check first
- Inventory site ID, WordPress and PHP versions, storage mode, optimizer, migration tool, attachment count, REST consumers, cache layers, and the approved read-only query.
- Classify metadata as valid integer, numeric string, decimal, blank, null, array, corrupt serialization, missing key, local missing, remote-only, or size mismatch.
- Sample REST collection, detail, edit context, search, pagination, media modal, featured image, and block-editor requests for each signature without logging private filenames publicly.
- Correlate first-seen time and site clusters with plugin deployments, imports, restores, offload jobs, optimizer runs, and custom metadata writers.
- Export affected IDs, repair only known values in small batches, verify API and editor behavior, then alert if the malformed signature reappears.
Field notes
- Write the expected result before changing anything and keep one repeatable synthetic fixture for the full test window.
- Record exact versions and UTC timestamps because caches, retries, scheduled actions, and deployments can change the evidence between checks.
- Test the public path and the stored server-side result, not only an admin preview, isolated command, or API response.
- Review the result again after the relevant cache, queue, cron, webhook, and observation window has completed.
Useful command or data shape
Adapt paths, IDs, and privacy handling to the site before running commands or storing data on production.
site_id,attachment_id,meta_type,stored_size,source_state,rest_status,writer,decision
site-01,8821,string,245812,local,200,migration,review
site-03,1902,array,null,remote,200,unknown,hold
Why this usually happens
- A migration serializes an integer through a different data type.
- An offload or optimization job writes partial metadata during a concurrent read.
- A custom integration reuses the filesize key for structured data.
- A repair tool derives zero when the local file is absent even though the remote object exists.
Decision rule
Do not normalize fleet-wide. Repair only attachments with a known intended size and source, preserve the before export, and fix the component that recreates malformed metadata.
Production verification checklist
- Every affected record is classified by site, attachment, type, and source state.
- REST and editor paths remain valid for all fixture classes.
- Repaired IDs reconcile with authoritative local or remote bytes.
- The same bad signature does not return after the writing job runs.
Safe fix order
Use a sequence that makes each result easy to prove. Stop when new evidence changes the scope or owner of the problem.
- Run a read-only fleet inventory
- Cluster malformed signatures
- Identify authoritative size and writer
- Repair reversible known batches
- Alert on recurrence
Mistakes to avoid
- Changing production before recording exact versions, UTC timestamps, a stable fixture, the expected result, and a tested rollback point.
- Treating one successful screen as proof while logs, stored records, background jobs, caches, emails, APIs, and downstream systems remain unchecked.
- Testing only as an administrator instead of using the role, device, locale, cache state, request path, and failure branch that users actually reach.
- Leaving debug output, temporary exclusions, helper accounts, duplicate hooks, broad permissions, or relaxed firewall rules active after verification.
Questions teams ask during testing
Can I test this directly in production?
Start with read-only evidence. Use staging for package, code, checkout, form, permission, or cache changes. If a production canary is necessary, make it identifiable, reversible, monitored, and unable to expose personal data or charge a customer.
How do I avoid a false positive?
Repeat the same fixture with the same versions, URL, role, locale, cache state, and downstream integration. Compare the browser result, stored result, and logs instead of relying on one successful screen.
What evidence should I retain?
Keep UTC time, exact versions, request or record ID, expected result, actual result, relevant log lines, change made, rollback point, owner, and final verification. Redact credentials, tokens, and personal data.
When is the work complete?
Close it when the primary path passes, failure branches are understood, stored and downstream records reconcile, temporary changes are removed, monitoring is active, and the owner has the evidence packet.
What to tell the client or owner
Give the owner a concise packet with the affected workflow, exact versions, UTC test time, synthetic fixture ID, expected result, actual result, key logs, change made, rollback point, final result, unresolved risks, owner, and next review date. Remove credentials and personal data before sharing it.
When HandL WP should help
Bring in help when this affects leads, checkout, search visibility, security, paid media reporting, or a client production site. HandL WP can trace the issue through WordPress, hosting, cache, tracking, and Search Console, then verify the workflow after the technical fix.
If this is active on a production site, have HandL WP audit WordPress media metadata.
Related HandL WP guides
Use these related guides when the same issue touches tracking, security, checkout, or crawler visibility.
Helpful references