Skip to content

[6.x] Fix global set sites array being ordered by file modification time - #15298

Open
duncanmcclean wants to merge 1 commit into
6.xfrom
global-set-sites-order
Open

[6.x] Fix global set sites array being ordered by file modification time#15298
duncanmcclean wants to merge 1 commit into
6.xfrom
global-set-sites-order

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

This pull request fixes an issue where the UpdateGlobalVariables update script built the global set's sites array in a non-deterministic order.

This was happening because Stache\Traverser::traverse() sorts paths by their file modification time, not by name, so the update script wrote the sites out in whatever order the variable files happened to have been written in. When the mtimes tie, the traverser's name ordering survives, which is why it looked stable locally and only showed up on the slower Windows CI runners, where the writes straddle a second boundary.

This PR fixes it by ordering the sites by their position in the sites config, which is the same order the Control Panel writes when a global set is saved. Variables for sites that aren't in the config are kept and sorted last, so they don't get deleted by saveOrDeleteLocalizations() during an upgrade.

The test now writes its fixture files in a different order than it expects them back, so it catches the ordering on every platform rather than passing by accident on Linux and macOS.

Related: #15297

`Stache\Traverser::traverse()` sorts paths by modification time, so
`UpdateGlobalVariables` built the `sites` array in whatever order the
variable files happened to be written in. When the writes tie on mtime the
name order survives, which is why this only showed up on the slower Windows
CI runners.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mj2inC2cHsqnqD47JhiYbf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant