Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#47334 closed defect (bug) (duplicate)

_print_styles split styles incorrect when styles name fit in 128 characters

Reported by: awkwin's profile awkwin Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Script Loader Keywords:
Focuses: Cc:

Description

In this line https://github.com/WordPress/WordPress/blob/80aee4ae87343ea3990314c453793d334beb8ebb/wp-includes/script-loader.php#L2631 the style string is split every 128 characters. However, it can result in some edge cases that it leave dangling comma that would break load-styles.php

For example, in my sites

php > $s='dashicons,admin-bar,common,forms,admin-menu,dashboard,list-tables,edit,revisions,media,themes,about,nav-menus,wp-pointer,widgets,site-icon,l10n,buttons,wp-auth-check';
php > print_r(str_split($s,128));
Array
(
    [0] => dashicons,admin-bar,common,forms,admin-menu,dashboard,list-tables,edit,revisions,media,themes,about,nav-menus,wp-pointer,widgets
    [1] => ,site-icon,l10n,buttons,wp-auth-check
)

Change History (5)

#1 @ocean90
6 years ago

  • Component changed from Media to Script Loader
  • Keywords reporter-feedback added
  • Version 5.2 deleted

Hello @awkwin, welcome to WordPress Trac!

Thanks for your report. Can you explain what issue this is causing for you? The loaders are using $load = implode( '', $load ); to convert the array back to the full string so the position of the split shouldn't matter.

#2 @awkwin
6 years ago

Hi @ocean90,

After imploding, the splitted URL would be like

load-styles.php?...&load[]=dashicons,admin-bar,common... widgets&load[]=,site-icon,....

With extra comma load-styles.php would ignore the first list and only load site-icon and files listed after that

#3 @ocean90
6 years ago

Which part of load-styles.php is removing the first list? It's basically doing this:

<?php
$load = [ 'dashicons,admin-bar', ',site-icon,l10n' ];
echo implode( '', $load ); // dashicons,admin-bar,site-icon,l10n

#4 @awkwin
6 years ago

I traced load-styles.php and the query string order was swapped:

[0] => ,site-icon,l10n,buttons,wp-auth-check
[1] => dashicons,admin-bar,common,forms,admin-menu,dashboard,list-tables,edit,revisions,media,themes,about,nav-menus,wp-pointer,widgets

So the list became

,site-icon,l10n,buttons,wp-auth-checkdashicons,admin-bar,common,forms,admin-menu,dashboard,list-tables,edit,revisions,media,themes,about,nav-menus,wp-pointer,widgets.

Apparently we have query string sort enabled at the CDN so the order was swapped. Disabling query string sort resolved this issue.

#5 @ocean90
6 years ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Ah, yes, that makes sense. The issue has been reported in #45346 as well so I'm going to close this as a duplicate.

Note: See TracTickets for help on using tickets.