Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #41692, comment 44


Ignore:
Timestamp:
11/24/2025 06:14:03 AM (3 months ago)
Author:
westonruter
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #41692, comment 44

    initial v1  
    1212}}}
    1313
    14 There didn't appear to be test coverage for the error case, so this was not noticed. Nevertheless, the featured media '''does''' get updated, and this is because the parent method also calls this same `handle_featured_media()` method. However, when this happens the result is that `set_post_thumbnail()` is called twice. When passing the same values into that function a second time, the function returns `false` causing it to appear as if it failed, and then this causes the REST API endpoint to newly return with an error.
     14There didn't appear to be test coverage for the error case, so this was not noticed. Nevertheless, the featured media '''does''' get updated, and this is because the parent method also calls this same `handle_featured_media()` method. When the `$schema` is supplied, then this method gets called twice, calling `set_post_thumbnail()` two times. When passing the same values into that function a second time, the function returns `false` causing it to appear as if it failed, and then this causes the REST API endpoint to newly return with an error.
    1515
    1616@swissspidy @TimothyBlynJacobs @dlh @spacedmonkey Please review [https://github.com/WordPress/wordpress-develop/pull/8865 this PR] to validate the fix. Note how it includes an  update to `handle_featured_media()` to prevent calling `set_post_thumbnail()` when the `_thumbnail_id` is already set. The PR also increases test coverage for the error scenario.