Opened 8 weeks ago
Last modified 8 weeks ago
#63043 new defect (bug)
script-loader 'colors' src true invalid argument
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Script Loader | Keywords: | has-patch |
Focuses: | Cc: |
Description
https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/script-loader.php#L1587
<?php $styles->add( 'colors', true, array( 'wp-admin', 'buttons' ) );
true
is not a valid 2nd argument for add
, string|false
expected.
Change History (2)
This ticket was mentioned in PR #8437 on WordPress/wordpress-develop by @abcd95.
8 weeks ago
#1
- Keywords has-patch added
#2
@
8 weeks ago
Thank you for reporting this issue.
After testing, I found that changing true
to false
or an empty string breaks the admin color scheme functionality.
Upon closer inspection of wp_style_loader_src()
, it appears the current implementation expects $src to be a truthy value for the 'colors' handle to properly process it through parse_url()
. See this
While technically true doesn't match the expected string|false
type, it's a historical implementation detail that's working in practice. I think it's best to document this behavior rather than change it for backward compatibility.
Follow-up:
After further testing, I found that we can use any non-falsy string instead of true while maintaining the admin color scheme functionality. The wp_style_loader_src()
function only needs a truthy value to process.
This opens up an opportunity to use a more descriptive string that both satisfies type requirements and documents the intent. Options could include 'placeholder', 'dynamic-color-scheme', or even just '#'.
This is open for discussion and I'd appreciate any appropriate placeholder suggestion for this.
Trac ticket: https://core.trac.wordpress.org/ticket/63043