Skip to content

SVG metadata generation crashes when XML parsing returns false #2967

Description

@pirate-bot

Summary

Generating attachment metadata for an SVG can terminate the background image-regeneration request with Call to a member function attributes() on bool.

Expected behavior: An SVG whose metadata cannot be parsed does not crash attachment metadata generation.

Actual behavior: The metadata-generation callback dereferences a boolean parser result and throws an uncaught error.

Impact: The affected WooCommerce background image-regeneration job stops for the attachment that reaches this path.

Customer context

  • Product / area: Otter Blocks SVG attachment metadata generation
  • Version: 3.2.1
  • Environment: WordPress 7.0.3, PHP 8.2.33
  • Integration / third party: WooCommerce background image regeneration
  • Reported error / symptom: Call to a member function attributes() on bool during cron
  • Impact: 2 telemetry occurrences across 1 production site in the query window.

Reproduction notes

  1. Use Otter Blocks 3.2.1 in a non-VIP environment with SVG uploads enabled.
  2. Trigger wp_generate_attachment_metadata for an SVG attachment lacking width and height metadata, such as through WooCommerce image regeneration.
  3. If XML parsing yields a boolean rather than an XML object, the reported attributes() on bool error occurs.

Production reproduction evidence: 2 cron occurrences across 1 site. The exact SVG input and parser failure condition were not retained in the telemetry report.

Diagnosis

Conclusion

Production telemetry records an uncaught error at Main::generate_svg_attachment_metadata() when it invokes attributes() on a boolean. In the inspected 3.2.1 source, simplexml_load_file() is assigned to $svg and immediately dereferenced with no result validation. This directly explains the reported receiver type when parsing does not produce an XML object.

Where this likely occurs

  • User-visible surface: attachment metadata generation reached from WooCommerce's background image-regeneration cron workflow.
  • inc/class-main.phpMain::init() lines 42-48 registers Main::generate_svg_attachment_metadata() on wp_generate_attachment_metadata at PHP_INT_MAX for non-VIP environments.
  • inc/class-main.phpMain::generate_svg_attachment_metadata() lines 515-536 limits the path to image/svg+xml attachments without existing dimensions, then calls simplexml_load_file() at line 528 and $svg->attributes() at line 529 without checking the returned value.
  • Git history attributes lines 515-535 to commit 23f2f9b8 (feat: generate SVG metadata); the same code is present at tag v3.2.1.

Engineering notes

  • The crash report locates the failure in Otter code, not the bundled Themeisle SDK, so the issue routes to Codeinwp/otter-blocks.
  • The reported request is cron-driven and originates through WooCommerce's regeneration worker, but the callback is registered globally for WordPress attachment metadata generation in the inspected non-VIP path.
  • The triggering SVG content or filesystem condition is unavailable. PHP XML parser behavior was not independently verified from framework or PHP source in this workspace; the telemetry-confirmed boolean receiver and the unguarded dereference establish the observed failing branch.

Test coverage status

  • tests/test-svg-upload.php contains upload sanitization and MIME-type tests, including Test_SVG_Upload::test_svg_upload_sanitization() at lines 35-54.
  • No relevant coverage was found during inspection for Main::generate_svg_attachment_metadata() when XML parsing does not yield an object.

What to verify or explore next

  • Reproduce attachment metadata generation with an SVG that causes the parser to yield a non-object result.
  • Run the PHP SVG upload test suite and a WooCommerce image-regeneration workflow after reproducing the reported path.
  • Check whether unreadable attachment files and malformed SVG payloads reach the same callback branch.

Unknowns / follow-up

  • The telemetry payload does not include the source SVG or attachment-file accessibility state.
  • The occurrence count is limited to one observed site in the supplied query window; broader prevalence is unknown.

Confidence

Confidence: 99/100

The production stack trace resolves directly to Otter's SVG metadata callback, and the version 3.2.1 source dereferences the result of simplexml_load_file() without validating it. The reported boolean receiver exactly matches that unguarded path.

Crash telemetry

Occurrences 2
Distinct sites 1
First seen 2026-08-07 01:06 UTC
Last seen 2026-08-07 04:52 UTC
Crash location product:inc/class-main.php:529
Request context cron
Inside Themeisle SDK no
Product versions 3.2.1
WP versions 7.0.3
PHP versions 8.2.33
SDK versions 3.3.58

Source: automated crash report — otter-blocks, fingerprint 4c4c2c69d7a73241f48f90c9db4635a5
Generated by bug-report-triage (ID: bug-report-triage_6a757493e67d31.05918158)

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions