Skip to content

REST API: Make filter_wp_unique_filename() static to match core, plus avoid duplicate routes#75782

Merged
adamsilverstein merged 2 commits intotrunkfrom
fix/static-filter-wp-unique-filename
Feb 20, 2026
Merged

REST API: Make filter_wp_unique_filename() static to match core, plus avoid duplicate routes#75782
adamsilverstein merged 2 commits intotrunkfrom
fix/static-filter-wp-unique-filename

Conversation

@adamsilverstein
Copy link
Member

Summary

  • Makes Gutenberg_REST_Attachments_Controller::filter_wp_unique_filename() private static to match the core WP_REST_Attachments_Controller parent class after Editor: PHP backports for Client Side Media wordpress-develop#10868 (r61703)
  • Simplifies the method signature from 7 parameters to 4, matching core
  • Updates the closure in sideload_item() to use static function and self:: accordingly

Context

After the client-side media processing PHP backports were committed to WordPress core trunk (r61703), the core WP_REST_Attachments_Controller::filter_wp_unique_filename() method was declared as private static. The Gutenberg subclass still had it as a non-static private method, causing a fatal error:

Fatal error: Cannot make static method WP_REST_Attachments_Controller::filter_wp_unique_filename() non static in class Gutenberg_REST_Attachments_Controller

Test plan

  • Verify Gutenberg tests pass against WordPress core trunk
  • Verify media sideload functionality still works correctly

🤖 Generated with Claude Code

After WordPress/wordpress-develop#10868 (r61703), the core
`WP_REST_Attachments_Controller::filter_wp_unique_filename()` method
was changed to `private static`. This causes a fatal error in the
Gutenberg subclass which declares it as non-static.

Aligns the Gutenberg method signature with core by making it static
and simplifying the parameters to match.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Feb 20, 2026

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.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>

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

@adamsilverstein adamsilverstein added [Type] Bug An existing feature does not function as intended Backport from WordPress Core Pull request that needs to be backported to a Gutenberg release from WordPress Core No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core and removed Backport from WordPress Core Pull request that needs to be backported to a Gutenberg release from WordPress Core labels Feb 20, 2026
Since core trunk now registers the sideload route in
`WP_REST_Attachments_Controller::register_routes()`, only register
it in the Gutenberg subclass when the parent class doesn't already
have the `sideload_item` method. Updates the test accordingly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@adamsilverstein adamsilverstein changed the title REST API: Make filter_wp_unique_filename() static to match core REST API: Make filter_wp_unique_filename() static to match core, plus avoid duplicate routes Feb 20, 2026
@github-actions
Copy link

Flaky tests detected in 5061dba.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/22231044443
📝 Reported issues:

@adamsilverstein adamsilverstein merged commit 03a4bf9 into trunk Feb 20, 2026
39 checks passed
@adamsilverstein adamsilverstein deleted the fix/static-filter-wp-unique-filename branch February 20, 2026 16:38
@github-actions github-actions bot added this to the Gutenberg 22.7 milestone Feb 20, 2026
scruffian pushed a commit that referenced this pull request Feb 23, 2026
… avoid duplicate routes (#75782)

* REST API: Make `filter_wp_unique_filename()` static to match core

After WordPress/wordpress-develop#10868 (r61703), the core
`WP_REST_Attachments_Controller::filter_wp_unique_filename()` method
was changed to `private static`. This causes a fatal error in the
Gutenberg subclass which declares it as non-static.

Aligns the Gutenberg method signature with core by making it static
and simplifying the parameters to match.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Avoid duplicate sideload route registration when core already has it

Since core trunk now registers the sideload route in
`WP_REST_Attachments_Controller::register_routes()`, only register
it in the Gutenberg subclass when the parent class doesn't already
have the `sideload_item` method. Updates the test accordingly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@ockham
Copy link
Contributor

ockham commented Feb 24, 2026

Looks like I need to include this on the release/22.6 branch in order to cherry-pick #75817.

cc/ @ellatrix in case this has any implications for WP 7.0 Beta 1.

@ockham ockham added the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Feb 24, 2026
@ockham ockham modified the milestones: Gutenberg 22.7, Gutenberg 22.6 Feb 24, 2026
ockham pushed a commit that referenced this pull request Feb 24, 2026
… avoid duplicate routes (#75782)

* REST API: Make `filter_wp_unique_filename()` static to match core

After WordPress/wordpress-develop#10868 (r61703), the core
`WP_REST_Attachments_Controller::filter_wp_unique_filename()` method
was changed to `private static`. This causes a fatal error in the
Gutenberg subclass which declares it as non-static.

Aligns the Gutenberg method signature with core by making it static
and simplifying the parameters to match.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Avoid duplicate sideload route registration when core already has it

Since core trunk now registers the sideload route in
`WP_REST_Attachments_Controller::register_routes()`, only register
it in the Gutenberg subclass when the parent class doesn't already
have the `sideload_item` method. Updates the test accordingly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@ockham
Copy link
Contributor

ockham commented Feb 24, 2026

I just cherry-picked this PR to the release/22.6 branch to get it included in the next release: f6e37c0

@ockham ockham removed the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Feb 24, 2026
@mirka
Copy link
Member

mirka commented Feb 25, 2026

Yes, CI checks on the wp/7.0 branch seem to be failing due to this missing.

@t-hamano
Copy link
Contributor

@adamsilverstein @westonruter, This PR is only for the Gutenberg plugin and has nothing to do with core, but we should backport this PR to the wp/7.0 branch, right? Otherwise, the unit tests will fail in the wp/7.0 branch.

@t-hamano
Copy link
Contributor

There should be no harm in backporting this PR to wp/7.0, so let's do it.

@t-hamano t-hamano added the Backport to WP 7.0 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Feb 25, 2026
@github-actions github-actions bot removed the Backport to WP 7.0 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Feb 25, 2026
gutenbergplugin pushed a commit that referenced this pull request Feb 25, 2026
… avoid duplicate routes (#75782)

* REST API: Make `filter_wp_unique_filename()` static to match core

After WordPress/wordpress-develop#10868 (r61703), the core
`WP_REST_Attachments_Controller::filter_wp_unique_filename()` method
was changed to `private static`. This causes a fatal error in the
Gutenberg subclass which declares it as non-static.

Aligns the Gutenberg method signature with core by making it static
and simplifying the parameters to match.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Avoid duplicate sideload route registration when core already has it

Since core trunk now registers the sideload route in
`WP_REST_Attachments_Controller::register_routes()`, only register
it in the Gutenberg subclass when the parent class doesn't already
have the `sideload_item` method. Updates the test accordingly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added the Backported to WP Core Pull request that has been successfully merged into WP Core label Feb 25, 2026
@github-actions
Copy link

I just cherry-picked this PR to the wp/7.0 branch to get it included in the next release: 21b607c

pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Feb 26, 2026
CI run: #11059.

See #64595.

---

I've included a log of the Gutenberg changes with the following command:

git log --reverse --format="- %s" 23b566c72e9c4a36219ef5d6e62890f05551f6cb..022d8dd3d461f91b15c1f0410649d3ebb027207f | sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' | pbcopy

- Pattern Editing: Fix nested patterns/sections (WordPress/gutenberg#75772)
- QuickEdit: rename status label and remove extra labels in popup (WordPress/gutenberg#75824)
- Fix block editing modes not recomputing when isolated editor value changes (WordPress/gutenberg#75821)
- Synced patterns: Fix block editing mode of synced pattern content when nested in an unsynced pattern (WordPress/gutenberg#75818)
- Block Support: Fix custom CSS not saved when style schema is not defined (WordPress/gutenberg#75797)
- Gallery: Fixes keyboard focus escaping the lightbox overlay when navigating a gallery with Tab/Shift+Tab. (WordPress/gutenberg#75852)
- Navigation Overlay Close: Set Close as default text, rather than using a placeholder (WordPress/gutenberg#75692)
- RTC: Fix entity save call / initial persistence. (WordPress/gutenberg#75841)
- Real-time collaboration: Improve collaboration within the same rich text (WordPress/gutenberg#75703)
- Client Side Media: Add device/browser capability detection (WordPress/gutenberg#75863)
- Navigation editing: simplify edit/view buttons (WordPress/gutenberg#75819)
- Add core/icon block to theme.json schema (WordPress/gutenberg#75813)
- Fix error when undoing newly added pattern (WordPress/gutenberg#75850)
- Page List Item: Replace RawHTML with dangerouslySetInnerHTML for label and title (WordPress/gutenberg#75890)
- REST API: Make filter_wp_unique_filename() static to match core, plus avoid duplicate routes (WordPress/gutenberg#75782)
- RichText: useAnchor: Fix TypeError in virtual element (WordPress/gutenberg#75900)
- DataViews: Remove menu divider again. (WordPress/gutenberg#75908)
- Theme: Add build plugins to inject design token fallbacks (WordPress/gutenberg#75901)
- Theme: Remove global stylesheet (WordPress/gutenberg#75879)
- Real-time collaboration: Remove ghost awareness state explicitly when refreshing (WordPress/gutenberg#75883)
- Real-time collaboration: Expand mergeCrdtBlocks() automated testing (WordPress/gutenberg#75923)
- Fix client-side media file naming (WordPress/gutenberg#75817)
- Add: Connectors screen (WordPress/gutenberg#75833)
- Merge document meta into state map (WordPress/gutenberg#75830)
- Move WordPress meta key from sync package to core-data (WordPress/gutenberg#75846)
- Bugfix: Fix casing of getPersistedCRDTDoc (WordPress/gutenberg#75922)
- Add debug logging to SyncManager (WordPress/gutenberg#75924)
- DataForm: fix label colors (WordPress/gutenberg#75730)
- DataViews: minimize padding for primary action buttons (WordPress/gutenberg#75721) (WordPress/gutenberg#75947)
- Connectors: Add `_ai_` prefix to connector setting names and fix naming inconsistencies (WordPress/gutenberg#75948)
- Connectors: Unhook Core callbacks in Gutenberg coexistence (WordPress/gutenberg#75935)
- Unsynced patterns: Rename 'Disconnect pattern' to 'Detach pattern' in context menu (WordPress/gutenberg#75807)
- Editor: Remove View dropdown and pinned items from revisions header (WordPress/gutenberg#75951)
- Fix: Template revisions infinite spinner (WordPress/gutenberg#75953)
- Backport: Avoid flickering while refreshing (WordPress/gutenberg#74572) (WordPress/gutenberg#75952)
- Add wp_ prefix to real time collaberation option. (WordPress/gutenberg#75837)


git-svn-id: https://develop.svn.wordpress.org/trunk@61750 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Feb 26, 2026
CI run: WordPress/wordpress-develop#11059.

See #64595.

---

I've included a log of the Gutenberg changes with the following command:

git log --reverse --format="- %s" 23b566c72e9c4a36219ef5d6e62890f05551f6cb..022d8dd3d461f91b15c1f0410649d3ebb027207f | sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' | pbcopy

- Pattern Editing: Fix nested patterns/sections (WordPress/gutenberg#75772)
- QuickEdit: rename status label and remove extra labels in popup (WordPress/gutenberg#75824)
- Fix block editing modes not recomputing when isolated editor value changes (WordPress/gutenberg#75821)
- Synced patterns: Fix block editing mode of synced pattern content when nested in an unsynced pattern (WordPress/gutenberg#75818)
- Block Support: Fix custom CSS not saved when style schema is not defined (WordPress/gutenberg#75797)
- Gallery: Fixes keyboard focus escaping the lightbox overlay when navigating a gallery with Tab/Shift+Tab. (WordPress/gutenberg#75852)
- Navigation Overlay Close: Set Close as default text, rather than using a placeholder (WordPress/gutenberg#75692)
- RTC: Fix entity save call / initial persistence. (WordPress/gutenberg#75841)
- Real-time collaboration: Improve collaboration within the same rich text (WordPress/gutenberg#75703)
- Client Side Media: Add device/browser capability detection (WordPress/gutenberg#75863)
- Navigation editing: simplify edit/view buttons (WordPress/gutenberg#75819)
- Add core/icon block to theme.json schema (WordPress/gutenberg#75813)
- Fix error when undoing newly added pattern (WordPress/gutenberg#75850)
- Page List Item: Replace RawHTML with dangerouslySetInnerHTML for label and title (WordPress/gutenberg#75890)
- REST API: Make filter_wp_unique_filename() static to match core, plus avoid duplicate routes (WordPress/gutenberg#75782)
- RichText: useAnchor: Fix TypeError in virtual element (WordPress/gutenberg#75900)
- DataViews: Remove menu divider again. (WordPress/gutenberg#75908)
- Theme: Add build plugins to inject design token fallbacks (WordPress/gutenberg#75901)
- Theme: Remove global stylesheet (WordPress/gutenberg#75879)
- Real-time collaboration: Remove ghost awareness state explicitly when refreshing (WordPress/gutenberg#75883)
- Real-time collaboration: Expand mergeCrdtBlocks() automated testing (WordPress/gutenberg#75923)
- Fix client-side media file naming (WordPress/gutenberg#75817)
- Add: Connectors screen (WordPress/gutenberg#75833)
- Merge document meta into state map (WordPress/gutenberg#75830)
- Move WordPress meta key from sync package to core-data (WordPress/gutenberg#75846)
- Bugfix: Fix casing of getPersistedCRDTDoc (WordPress/gutenberg#75922)
- Add debug logging to SyncManager (WordPress/gutenberg#75924)
- DataForm: fix label colors (WordPress/gutenberg#75730)
- DataViews: minimize padding for primary action buttons (WordPress/gutenberg#75721) (WordPress/gutenberg#75947)
- Connectors: Add `_ai_` prefix to connector setting names and fix naming inconsistencies (WordPress/gutenberg#75948)
- Connectors: Unhook Core callbacks in Gutenberg coexistence (WordPress/gutenberg#75935)
- Unsynced patterns: Rename 'Disconnect pattern' to 'Detach pattern' in context menu (WordPress/gutenberg#75807)
- Editor: Remove View dropdown and pinned items from revisions header (WordPress/gutenberg#75951)
- Fix: Template revisions infinite spinner (WordPress/gutenberg#75953)
- Backport: Avoid flickering while refreshing (WordPress/gutenberg#74572) (WordPress/gutenberg#75952)
- Add wp_ prefix to real time collaberation option. (WordPress/gutenberg#75837)

Built from https://develop.svn.wordpress.org/trunk@61750


git-svn-id: http://core.svn.wordpress.org/trunk@61056 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants