Skip to content

Media: Fix wp_show_heic_upload_error() assigning to an undeclared variable. - #12830

Open
softglazee wants to merge 1 commit into
WordPress:trunkfrom
softglazee:fix/65802-heic-upload-error-variable
Open

Media: Fix wp_show_heic_upload_error() assigning to an undeclared variable.#12830
softglazee wants to merge 1 commit into
WordPress:trunkfrom
softglazee:fix/65802-heic-upload-error-variable

Conversation

@softglazee

Copy link
Copy Markdown

The wp_show_heic_upload_error() function assigned the HEIC upload error flag to an undeclared $plupload_init variable instead of the $plupload_settings parameter. As a result, the flag never reached the returned array. This behavior was introduced in [58849] and shipped in WordPress 6.7.0.

This patch updates the variable name to $plupload_settings so the flag is properly appended, and adds unit tests covering both the supported and unsupported HEIC editor cases.

Testing Instructions

These tests were run on trunk 8c3c976c25 using PHP 8.3.32 and PHPUnit 9.6.35.

  1. Run the newly added tests:
    npm run test:php -- --filter test_wp_show_heic_upload_error
  2. Confirm the tests pass with the fix:
    OK (2 tests, 7 assertions)
  3. Revert the change in src/wp-includes/media.php to test the baseline failure:
    git stash push src/wp-includes/media.php
  4. Re-run the tests:
    npm run test:php -- --filter test_wp_show_heic_upload_error
  5. Confirm the expected failure occurs without the patch:
    1) Tests_Media::test_wp_show_heic_upload_error_adds_flag_when_not_supported
    Failed asserting that an array has the key 'heic_upload_error'.
  6. Restore the change:
    git stash pop

Trac ticket: https://core.trac.wordpress.org/ticket/65802

Use of AI Tools

Used for: Investigating the underlying code paths, structuring the PHPUnit test scaffolding, and generating shell commands for the environment. The initial finding, manual measurements, Trac ticket description, and commit message are my own work.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props softglaze, irozum.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

…iable.

The function assigned the error flag to an undeclared $plupload_init variable instead of the $plupload_settings parameter, preventing the flag from reaching the returned array.

This behavior was introduced in [58849] and shipped in WordPress 6.7.0.

Adds unit tests covering both the supported and unsupported cases.

See #65802.

@irozum irozum left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean one-character-scope fix — $plupload_init was never declared, so the heic_upload_error flag silently never reached the returned settings array, unlike the WebP/AVIF flags set elsewhere. Good catch and nicely isolated.

I checked out the branch, reverted just the media.php line to confirm the new test actually fails without the fix (it does, cleanly), then restored it and confirmed both new tests plus the full Tests_Media suite (479 tests) pass. composer lint:errors and phpstan are clean on the changed files (the reported violations are pre-existing, in wp-tests-config.php and generated registry.php).

I also traced both callers per the ticket's own research: on the plupload_default_settings path the bug was already masked by the redundant inline check in wp_plupload_default_settings() (media.php:4553), so this only restores user-visible behavior on the plupload_init path (media-new.php, media-upload.php iframe) — matches what's in the ticket. No concerns.

@softglazee

Copy link
Copy Markdown
Author

Thanks @irozum for checking out the branch and running the red-green proof independently and appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants