Ensure the string from HtaccessWriter::defaultProtectedDirs can be translated

Created on 21 June 2024, 4 months ago

Problem/Motivation

alexpott spotted this while reviewing this section from system.install as part of #3123067: Fix 'Drupal.Semantics.FunctionT.NotLiteralString' coding standard β†’ .

    foreach ($htaccessWriter->defaultProtectedDirs() as $protected_dir) {
      $htaccess_file = $protected_dir->getPath() . '/.htaccess';
      // Check for the string which was added to the recommended .htaccess file
      // in the latest security update.
      if (!file_exists($htaccess_file) || !($contents = @file_get_contents($htaccess_file)) || !str_contains($contents, 'Drupal_Security_Do_Not_Remove_See_SA_2013_003')) {
        $url = 'https://www.drupal.org/SA-CORE-2013-003';
        $requirements[$htaccess_file] = [
          'title' => new TranslatableMarkup($protected_dir->getTitle()),

The comment copied here for convenience,

This almost certainly has never resulted in any of the strings in \Drupal\Core\File\HtaccessWriter::defaultProtectedDirs() being translated. If we want this to work either we need to change the strings to translatable strings in \Drupal\Core\File\HtaccessWriter::defaultProtectedDirs() or we need to list the strings somewhere and somehow that POTX is going to extract them. I think we should change \Drupal\Core\File\ProtectedDirectory to work with translatable strings.

Steps to reproduce

Proposed resolution

TBA

Remaining tasks

TBA

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated about 2 hours ago

Created by

πŸ‡³πŸ‡ΏNew Zealand quietone

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

Comments & Activities

Production build 0.71.5 2024