Problem/Motivation
When using the Bootstrap Barrio theme or subtheme you get directory access errors and file rename errors in the Twig directory when running under Windows/IIS.
Steps to reproduce
Open a site running under IIS 10 and Drupal 10.3.x, PHP 8.3.12, MySQL 8.0.39, but PHP and MySQL versions probably irrelevant.
You get errors like
User warning: mkdir(): Permission Denied in Drupal\Component\PhpStorage\FileStorage->createDirectory() (line 123 of core\lib\Drupal\Component\PhpStorage\FileStorage.php).
Warning: rename(sites/default/files/php/twig/.4Dsb9cXDdpWEyXnXMa2kO0BnFjA,sites/default/files/php/twig/67000377e1daa_bootstrap_barrio:menu_col_JNIvb5q6me012iSYuYuVxcV6m/uz2H06QmL6F0P_gLVdYkLJqgQk5OKx6QathIvhyWzH8.php): The system cannot find the path specified (code: 3) in Drupal\Component\PhpStorage\MTimeProtectedFastFileStorage->save() (line 88 of core\lib\Drupal\Component\PhpStorage\MTimeProtectedFastFileStorage.php).
The colon after barrio is illegal in Windows.
You don't expect such errors.
Proposed resolution
This is caused by directory and file names containing characters that are illegal in Windows being used. They can be fixed by replacing those characters with underscores. This involves adding a function to do this and calling it.
Remaining tasks
Create Pull Request to add these changes.
User interface changes
None
Introduced terminology
None.
API changes
Add a function to replace the illegal characters if running Windows in
\web\core\lib\Drupal\Component\PhpStorage\MTimeProtectedFastFileStorage.php
and call it in relevant places in that script and
t\web\core\lib\Drupal\Component\PhpStorage\FileStorage.php.
Data model changes
None
Release notes snippet
The function does nothing if PHP_OS is not WINNT.
The basic code in the added function was generated by Copilot.