Fix: Site icon in the toolbar is broken (mixed content) in the admin when siteurl is stored with http:// on an SSL site - #12655
Conversation
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Pull request overview
Fixes mixed-content breakage for the Site Icon used in the admin toolbar when the stored attachment URL is http:// but the admin is loaded over SSL, by normalizing the Site Icon URL to the current request scheme.
Changes:
- Update
get_site_icon_url()to return a scheme-corrected attachment URL viaset_url_scheme().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
Just out of curiosity, does this mean the issue could occur anywhere we use |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
tests/phpunit/tests/general/template.php:170
- This test mutates
$_SERVER['HTTPS']and unconditionally unsets it at the end, which can leak global state into later tests when$_SERVER['HTTPS']was already set. Saving the previous value, forcing a non-SSL baseline for$url_http, and restoring the original value will make the test isolated and more reliable.
// Simulate the same admin request served over HTTPS.
$_SERVER['HTTPS'] = 'on';
$url_https = get_site_icon_url();
unset( $_SERVER['HTTPS'] );
Yeah it could. Because the function would return the URL and currently we are applying the fix limited to site icon URL only and we are setting the scheme as expected. I guess the issue can be more broader and should not be limited only to site icon, but wherever this is used. Though this needs verification and would verify the same, if that is the case. |
|
@mukeshpanchal27 yes, it can happen with any attachment call but it seems to have been done on purpose to avoid "https" leaking into attachment added to post content resulting in mixed content. That's why I went with a safer suggestion (site icon only) |
tyxla
left a comment
There was a problem hiding this comment.
Fix makes sense to me 👍
I'm not super sure about the test coverage - at first glance it feels a bit like a test is unnecessary, but at the same time I can imagine there are cases that we might want to test separately like:
- if admin is accessed via http (in the case of
force_ssl_admin()being off or no redirect yet) - with multisite, if we're requesting an icon for an HTTP-only blog during an HTTPS request for example
What do you all think?
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
tests/phpunit/tests/general/template.php:166
- This test mutates
$_SERVER['HTTPS']but doesn’t control$_SERVER['SERVER_PORT'], so the “HTTP baseline” can still be detected as SSL in environments whereSERVER_PORTis 443. It also risks leaking modified$_SERVERstate into later tests if an assertion fails. Save/restore the original values and explicitly set a non-SSL port for the baseline (and restore everything in afinally).
unset( $_SERVER['HTTPS'] );
$this->assertFalse( is_ssl(), 'Baseline request should not be detected as SSL.' );
|
@westonruter I see the PR author has addressed all the comments. Can you check and see if the PR is good now? I believe, this fixes the regression. Thanks! |
|
Testing notes (the hard way) 🥲 To reproduce this bug locally, you need the admin running over HTTPS — which sounds simple until you realise the default Docker dev environment only speaks HTTP. What it actually took:
Once that was all in place, the bug was 100% reproducible — the site icon in the admin toolbar was blocked as mixed content when the stored attachment URL was The fix is correct. Tested and verified. ✅ (Might be worth adding a note to the PR description about needing an HTTPS environment to test this — future reviewers will thank you.) |
|
Due to a change in my Git username, my WordPress.org profile link is now broken. |
Trac ticket: https://core.trac.wordpress.org/ticket/65696
Screenshot
Use of AI Tools
Update: Use Claude Code Opus 4.8 for drafting test case.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.