[wp-trac] [WordPress Trac] #59489: Stale core block style cache updates not working on Windows OS
WordPress Trac
noreply at wordpress.org
Thu Sep 28 13:31:59 UTC 2023
#59489: Stale core block style cache updates not working on Windows OS
--------------------------+-----------------------------
Reporter: wildworks | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
In [56528], The old core block style cache that was stored as a full path
is now replaced by a new relative path. However, this cache update doesn't
seem to be working on Windows.
As far as I've researched, the problem is related to this code:
https://github.com/WordPress/wordpress-
develop/blob/e3a612a97c4c45acd7613779a46d86860e76cc65/src/wp-
includes/blocks/index.php#L59-L76
This code does not correctly replace the old cache with a relative path on
Windows OS, as below:
- If the cache's WordPress version is different from the current WordPress
version, try to create a new cache by replacing the full path with a
relative path.
- Use the glob function to find the full path of the stylesheet. All path
separators in the returned value array are forward slashes:
`D:/_local/WordPress/wp6.4/app/public/wp-includes/blocks/archives
/editor-rtl.css`
`D:/_local/WordPress/wp6.4/app/public/wp-includes/blocks/archives
/editor-rtl.min.css`
- However, the `BLOCKS_PATH` constant on which the substitution is based
includes a backslash in the path separator, as shown below:
`D:\_local\WordPress\wp6.4\app\public/wp-includes/blocks/`
- This results in a cache that still has the full path.
- Subsequent style enqueues expect the file path to be relative, so the
style will not be registered.
This problem seems to be solved by adding normalization to `str_replace()`
function as shown below:
{{{
$files = array_map(
static function ( $file ) {
return str_replace( wp_normalize_path( BLOCKS_PATH ), '',
$file );
},
$files
);
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59489>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list