Skip to content

Media: Send the isolation header through core when available - #86542

Merged
adamsilverstein merged 2 commits into
trunkfrom
fix/defer-dip-header-to-core
Nov 10, 2026
Merged

adamsilverstein merged 2 commits into
trunkfrom
fix/defer-dip-header-to-core

Conversation

@adamsilverstein

Copy link
Copy Markdown
Member

What?

See https://core.trac.wordpress.org/ticket/66490 (item 1) and the core PR WordPress/wordpress-develop#15855

Send the Document-Isolation-Policy header through core's wp_send_document_isolation_policy_header() when it exists, so core knows Gutenberg isolated the editor screens.

Why?

Claude worked through the core side, short version below:

Core 7.2 loads the media frame upload pipeline only on screens it knows are cross-origin isolated. It used to also count any Document-Isolation-Policy header in headers_list(), mostly so Gutenberg's own header would count. That also pulled plugin screens that isolate themselves for other reasons (the Elementor editor) into the pipeline, so the core PR drops the header check and only trusts the flag wp_send_document_isolation_policy_header() sets.

Without this change, the block editor's media modal would fall back to classic uploads once the core PR lands.

How?

gutenberg_send_document_isolation_policy_header() still applies the gutenberg_use_document_isolation_policy filter, then calls core's function when it is available. On older WordPress versions it sends the header directly as before. Gutenberg still decides which screens to isolate.

Testing Instructions

  1. Check out the core PR above, in Chrome 137+ over HTTPS or localhost, with Gutenberg active.
  2. Open the block editor, open the media modal from an Image block, and upload a JPEG.
  3. Without this PR: the upload goes to async-upload.php. With it: it goes through /wp/v2/media, /sideload and /finalize.
  4. On core trunk without the core PR, the upload should go through the pipeline either way.

Use of AI Tools

Code and description written with 🤖 Claude Code. I will review and test.

🤖 Generated with Claude Code

https://claude.ai/code/session_018vwYjVChF8EN33VU3DGbni

WordPress 7.2 only loads the media frame upload pipeline on screens that wp_send_document_isolation_policy_header() isolated, so it can tell its own isolation apart from a plugin that sends the header for reasons of its own. Sending the header directly would leave the media modal on classic uploads in the block editor.

Gutenberg keeps deciding which screens to isolate and the gutenberg_use_document_isolation_policy filter still applies. Older WordPress versions without core's function keep the direct header call.

See https://core.trac.wordpress.org/ticket/66490.

Claude-Session: https://claude.ai/code/session_018vwYjVChF8EN33VU3DGbni
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

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: andrewserong <andrewserong@git.wordpress.org>

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 5e94a79 trunk % Change
timeToFirstByte 42.85 ms +12.14% -3.97% 42.85 ms +11.55% -2.68% 0%
largestContentfulPaint 70 ms +2.86% -8.57% 68 ms +11.76% -5.88% 2.94%
lcpMinusTtfb 24.05 ms +26.4% -4.99% 24.05 ms +23.7% -6.65% 0%
wpBeforeTemplate 22.08 ms +14.72% -1.86% 22.41 ms +7.81% -2.72% -1.47%
wpTemplate 17.14 ms +4.2% -5.25% 17.37 ms +3.63% -6.22% -1.32%
wpTotal 39.58 ms +12.63% -3.84% 39.55 ms +9.13% -2.93% 0.08%
wpMemoryUsage 7.72 MB +0% -0% 7.68 MB +0% -0% 0.43%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 5e94a79 trunk % Change
timeToFirstByte 34.6 ms +6.65% -1.73% 34.65 ms +14.14% -1.73% -0.14%
largestContentfulPaint 64 ms +9.38% -0% 64 ms +6.25% -6.25% 0%
lcpMinusTtfb 29.5 ms +1.53% -2.37% 28.05 ms +4.63% -6.6% 5.17%
wpBeforeTemplate 19.02 ms +0.84% -1.31% 18.94 ms +9.77% -1.8% 0.42%
wpTemplate 12.98 ms +7.24% -3.54% 13.04 ms +5.44% -3.76% -0.46%
wpTotal 31.82 ms +7.39% -1.48% 32 ms +13.53% -2.06% -0.56%
wpMemoryUsage 6.41 MB +0% -0% 6.37 MB +0% -0% 0.53%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 5e94a79 trunk % Change
mediaProcessingJpeg 328.44 ms +1.11% -0.43% 327.88 ms +0.38% -1.24% 0.17%
mediaProcessingAvif 4848.03 ms +0.37% -0.27% 4888.83 ms +0.34% -0.34% -0.83%
mediaProcessingJpegToAvif 3405.16 ms +0.3% -0.56% 3390.12 ms +0.27% -0.21% 0.44%

media-upload

Metric 5e94a79 trunk % Change
jpegUploadProcessing 1467.7 ms +1.46% -1.04% 1451.01 ms +0.98% -0.42% 1.15%
pngUploadProcessing 230.69 ms +3.46% -4.14% 234.64 ms +4.44% -0.47% -1.68%
largeJpegUploadProcessing 1441.95 ms +0.7% -0.96% 1435.65 ms +1.11% -0.69% 0.44%
multipleImageUploadProcessing 1510.09 ms +1.9% -1.17% 1505.85 ms +1.79% -0.85% 0.28%

post-editor

Metric 5e94a79 trunk % Change
serverResponse 297.25 ms +9.88% -4.1% 318.69 ms +6.13% -6.68% -6.73%
firstPaint 340.88 ms +6.1% -5.2% 329.94 ms +7.24% -7.36% 3.32%
domContentLoaded 634.99 ms +1.47% -1.87% 662.12 ms +3.25% -2.55% -4.1%
loaded 635.8 ms +1.45% -1.87% 662.98 ms +3.3% -2.54% -4.1%
firstContentfulPaint 363.25 ms +2.58% -1.83% 373.58 ms +2.89% -3.41% -2.77%
firstBlock 1696.55 ms +0.91% -0.96% 1771.49 ms +1.61% -1.13% -4.23%
type 14.48 ms +4.42% -1.31% 15.52 ms +7.99% -4.96% -6.7%
typeWithoutInspector 14.7 ms +4.08% -8.84% 16.45 ms +7.42% -8.09% -10.64%
typeWithTopToolbar 18.7 ms +14.81% -5.13% 20 ms +3.7% -9.2% -6.5%
typeContainer 6.61 ms +3.03% -14.67% 7.04 ms +11.65% -14.35% -6.11%
focus 95.76 ms +2.9% -5.9% 91.97 ms +1.97% -5.47% 4.12%
firstFocus 196.77 ms +0% -0% 204.12 ms +0% -0% -3.6%
selectAll 302.77 ms +1.75% -2.24% 318.54 ms +1.36% -3.26% -4.95%
undo 23.57 ms +7% -4.29% 26.98 ms +5.52% -9.41% -12.64%
listViewOpen 65.73 ms +3.71% -3.19% 64.1 ms +6.9% -6.9% 2.54%
inserterOpen 35.54 ms +5.63% -10.66% 37.94 ms +11.7% -4.16% -6.33%
inserterHover 9.65 ms +9.74% -4.77% 10.33 ms +9.2% -9.2% -6.58%
inserterSearch 6.7 ms +8.81% -6.87% 7.43 ms +4.17% -3.23% -9.83%
loadPatterns 532.83 ms +10.95% -2.54% 547 ms +1.86% -4.78% -2.59%
wpTotal 288.65 ms +10.19% -4.19% 310.09 ms +6.29% -6.86% -6.91%
wpMemoryUsage 14.77 MB +0% -0% 14.73 MB +0% -0% 0.24%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 5e94a79 trunk % Change
serverResponse 335.35 ms +0.85% -9.94% 300.32 ms +8.6% -1.57% 11.66%
firstPaint 380.87 ms +7.33% -6.42% 339.47 ms +16.57% -6.99% 12.2%
domContentLoaded 717.43 ms +0.64% -1.46% 689.39 ms +0.37% -2.46% 4.07%
loaded 718.37 ms +0.63% -1.45% 690.26 ms +0.38% -2.46% 4.07%
firstContentfulPaint 411.64 ms +2.92% -2.36% 386.79 ms +2.31% -0.81% 6.42%
firstBlock 2133.83 ms +0.95% -2.54% 2097.08 ms +1.78% -1.49% 1.75%
type 16.23 ms +10.6% -7.02% 16.28 ms +9.21% -7.13% -0.31%
navigate 99.02 ms +11.95% -2.89% 105.69 ms +4.89% -4.66% -6.31%
loadPatterns 1110.5 ms +5.66% -14.35% 1158.09 ms +3.85% -6.43% -4.11%
loadPages 937.87 ms +8.88% -2.81% 938.37 ms +11.13% -0.87% -0.05%
wpTotal 326.9 ms +0.88% -10.22% 291.68 ms +8.93% -1.59% 12.07%
wpMemoryUsage 12.78 MB +0% -0% 12.75 MB +0% -0% 0.27%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

38e6b8e Run

🏁 Flaky tests

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.

Actions are reachable via RIGHT/LEFT arrow keys in /test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator:  getByRole('row', { name: 'Page One Edit Actions' }).getByRole('button', { name: 'Edit' })
Expected: focused
Received: inactive
Timeout:  5000ms

Call log:
  - Expect "toBeFocused" getByRole('row', { name: 'Page One Edit Actions' }).getByRole('button', { name: 'Edit' }) with timeout 5000ms
  - waiting for getByRole('row', { name: 'Page One Edit Actions' }).getByRole('button', { name: 'Edit' })
    14 × locator resolved to <button type="button" tabindex="-1" class="components-button is-small" id="view-list-0-206-primary-action-edit-post">Edit</button>
       - unexpected value "inactive"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js:172:5

Allows widget deletion to be undone in /test/e2e/specs/widgets/editing-widgets.spec.js, passed after 1 failed attempt.

Page List converts to Navigation Links with entity bindings in /test/e2e/specs/editor/blocks/navigation.spec.js, passed after 1 failed attempt.
Error: expect(locator).toContainText(expected) failed

Locator: getByRole('region', { name: 'Editor settings' }).getByRole('tabpanel', { name: 'Content' }).getByRole('button', { name: /Link to:/ })
Expected substring: "test-page-1"
Received string:    "Link to:Cat/catPagePublished"
Timeout: 5000ms

Call log:
  - Expect "toContainText" getByRole('region', { name: 'Editor settings' }).getByRole('tabpanel', { name: 'Content' }).getByRole('button', { name: /Link to:/ }) with timeout 5000ms
  - waiting for getByRole('region', { name: 'Editor settings' }).getByRole('tabpanel', { name: 'Content' }).getByRole('button', { name: /Link to:/ })
    14 × locator resolved to <button type="button" aria-expanded="false" aria-haspopup="dialog" class="components-button link-preview-button is-next-40px-default-size is-secondary">…</button>
       - unexpected value "Link to:Cat/catPagePublished"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/navigation.spec.js:1949:31
Undo restores the post selection when another synced entity is loaded (RTC WebSocket) in /test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 2
+ Received  + 2

  Object {
    "attributeKey": "content",
    "blockIndex": 0,
    "content": "abcdef",
-   "endOffset": 3,
-   "offset": 3,
+   "endOffset": 1,
+   "offset": 1,
  }

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts:363:5
Undo restores the post selection when another synced entity is loaded in /test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 2
+ Received  + 2

  Object {
    "attributeKey": "content",
    "blockIndex": 0,
    "content": "abcdef",
-   "endOffset": 3,
-   "offset": 3,
+   "endOffset": 1,
+   "offset": 1,
  }

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts:363:5
three users concurrently edit a large post with diverse blocks in /test/e2e/specs/editor/collaboration/collaboration-stress.spec.ts, passed after 1 failed attempt.
TimeoutError: locator.waitFor: Timeout 17500ms exceeded.
Call log:
  - waiting for getByRole('button', { name: /Collaborators list/ }) to be visible

    at map (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/fixtures/collaboration-utils.ts:193:7)
    at CollaborationUtils.waitForMutualDiscovery (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/fixtures/collaboration-utils.ts:188:10)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/collaboration-stress.spec.ts:416:28

38e6b8e Run

@adamsilverstein adamsilverstein self-assigned this Nov 10, 2026
@adamsilverstein
adamsilverstein requested review from swissspidy and removed request for spacedmonkey November 10, 2026 13:37
@adamsilverstein adamsilverstein added [Type] Bug An existing feature does not function as intended No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core labels Nov 10, 2026

@andrewserong andrewserong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@adamsilverstein

adamsilverstein commented Nov 10, 2026 •

Copy link
Copy Markdown
Member Author

LGTM!

Thanks @andrewserong. This tested well for me when I manually tested so I am going to merge it.

@adamsilverstein
adamsilverstein enabled auto-merge (squash) November 10, 2026 23:11
@adamsilverstein
adamsilverstein merged commit f74ee68 into trunk Nov 10, 2026
78 checks passed
@adamsilverstein
adamsilverstein deleted the fix/defer-dip-header-to-core branch November 10, 2026 23:30
@github-actions github-actions Bot added this to the Gutenberg 24.5 milestone Nov 10, 2026
wporg-sync pushed a commit to WordPress/wordpress-develop that referenced this pull request Nov 16, 2026
Fix an issue where a plugin screen that sends its own `Document-Isolation-Policy` header, such as the Elementor editor, got the client-side upload pipeline in every media frame without asking for it. `wp_is_cross_origin_isolated_request()` treated any queued `Document-Isolation-Policy` header as a sign the screen was set up for the pipeline, so it could not tell core's isolation apart from a plugin's.

The function now returns true only when `wp_send_document_isolation_policy_header()` has sent the header. Media frames on a screen a plugin isolates itself upload through plupload again, as they did in 7.1. To opt a screen into the pipeline, call `wp_send_document_isolation_policy_header()` before `wp_enqueue_media()` runs.

The Gutenberg plugin sends the header itself on the editor screens, so its media modal uses classic uploads until a site updates to a release that includes WordPress/gutenberg#86542. Uploads made in the block editor itself are unaffected.

Follow-up to [64588].

Props andrewserong.
Fixes #66490.



git-svn-id: https://develop.svn.wordpress.org/trunk@65532 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Nov 16, 2026
Fix an issue where a plugin screen that sends its own `Document-Isolation-Policy` header, such as the Elementor editor, got the client-side upload pipeline in every media frame without asking for it. `wp_is_cross_origin_isolated_request()` treated any queued `Document-Isolation-Policy` header as a sign the screen was set up for the pipeline, so it could not tell core's isolation apart from a plugin's.

The function now returns true only when `wp_send_document_isolation_policy_header()` has sent the header. Media frames on a screen a plugin isolates itself upload through plupload again, as they did in 7.1. To opt a screen into the pipeline, call `wp_send_document_isolation_policy_header()` before `wp_enqueue_media()` runs.

The Gutenberg plugin sends the header itself on the editor screens, so its media modal uses classic uploads until a site updates to a release that includes WordPress/gutenberg#86542. Uploads made in the block editor itself are unaffected.

Follow-up to [64588].

Props andrewserong.
Fixes #66490.


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


git-svn-id: http://core.svn.wordpress.org/trunk@64605 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@paulopmt1 paulopmt1 added the [Feature] Media Anything that impacts the experience of managing media label Nov 17, 2026
arshidkv12 pushed a commit to arshidkv12/wordpress-develop that referenced this pull request Nov 21, 2026
Fix an issue where a plugin screen that sends its own `Document-Isolation-Policy` header, such as the Elementor editor, got the client-side upload pipeline in every media frame without asking for it. `wp_is_cross_origin_isolated_request()` treated any queued `Document-Isolation-Policy` header as a sign the screen was set up for the pipeline, so it could not tell core's isolation apart from a plugin's.

The function now returns true only when `wp_send_document_isolation_policy_header()` has sent the header. Media frames on a screen a plugin isolates itself upload through plupload again, as they did in 7.1. To opt a screen into the pipeline, call `wp_send_document_isolation_policy_header()` before `wp_enqueue_media()` runs.

The Gutenberg plugin sends the header itself on the editor screens, so its media modal uses classic uploads until a site updates to a release that includes WordPress/gutenberg#86542. Uploads made in the block editor itself are unaffected.

Follow-up to [64588].

Props andrewserong.
Fixes #66490.



git-svn-id: https://develop.svn.wordpress.org/trunk@65532 602fd350-edb4-49c9-b593-d223f7449a82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Media Anything that impacts the experience of managing media 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.

3 participants