Bootstrap Barrio theme gives errors under Windows/IIS

Created on 8 October 2024, 2 months ago

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.

πŸ› Bug report
Status

Active

Version

10.3 ✨

Component

bootstrap system

Created by

πŸ‡¬πŸ‡§United Kingdom spalmstrom

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @spalmstrom
  • Pipeline finished with Failed
    2 months ago
    Total: 1836s
    #304287
  • The merge request is enormous. Something seems wrong there.

  • Pipeline finished with Failed
    2 months ago
    #304320
  • Pipeline finished with Failed
    2 months ago
    Total: 225s
    #304334
  • Pipeline finished with Failed
    2 months ago
    Total: 258s
    #304376
  • πŸ‡³πŸ‡ΏNew Zealand quietone

    @spalmstrom, thanks for creating the MR. Unfortunately, it is still very large and not ready for review.

  • πŸ‡¬πŸ‡§United Kingdom spalmstrom

    This issue related to the attempted creation of files in Windows with illegal names. Hence, it might well apply in a WAMP environment, too, i.e. running Apache, not just IIS.

  • Status changed to Needs work 10 days ago
  • πŸ‡ΊπŸ‡ΈUnited States DanChadwick

    This is broader than the original report. I use apache (WAMP server) on windows and Radix version 6, which also has colons in template names.

    I think the sensitization could be done regardless of platform for simplicity.

  • πŸ‡ΊπŸ‡ΈUnited States DanChadwick

    I edited the issue to broaden it to its true scope: You can't use Single Directory Components and Windows together. The generated twig php files contains a colon.

    Bumping priority to Major since if you're hosting on windows, you can't use any theme that uses SDC.

  • πŸ‡ΊπŸ‡ΈUnited States DanChadwick

    Here's a simple solution. When generating cache keys for twig templates, there is already code which makes exceptions to avoid illegal characters and other code while avoids windows file name limitations. Simply replace colons with underscores when generating the cache key.

    I'm providing a patch on D10.3, but I suspect it will apply to 11.x.

Production build 0.71.5 2024