Append scaffolding .htaccess does not seem to work

Created on 8 January 2024, 5 months ago
Updated 10 January 2024, 5 months ago

Problem/Motivation

It seems like append doesn't work, following the documentation β†’ , nothing happens after composer install ...

Append, doesn't work

    "extra": {
        "drupal-scaffold": {
            "locations": {
                "web-root": "web/"
            },
            "file-mapping": {
                "web/.htaccess": {
                    "append": "assets/htaccess-php82.txt"
                }
            }
        },

The file assets/htaccess-php82.txt content:

AddType application/x-httpd-php82 .php

Patch, works

The patch method works well:

  "name": "my/project",
  ...
  "scripts": {
    "post-drupal-scaffold-cmd": [
      "cd web && patch -p1 <../assets/php82.patch"
    ]
  }

... with this in the patch file assets/php82.patch:

diff --git a/.htaccess b/.htaccess
index 4031da47..d5f674c3 100644
--- a/.htaccess
+++ b/.htaccess
@@ -1,3 +1,5 @@
+AddType application/x-httpd-php82 .php
+
 #
 # Apache/PHP/Drupal settings:
 #

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Closed: works as designed

Version

11.0 πŸ”₯

Component
ComposerΒ  β†’

Last updated about 23 hours ago

No maintainer
Created by

πŸ‡©πŸ‡°Denmark ressa Copenhagen

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

Comments & Activities

  • Issue created by @ressa
  • πŸ‡©πŸ‡°Denmark ressa Copenhagen
  • πŸ‡©πŸ‡°Denmark ressa Copenhagen
  • πŸ‡©πŸ‡°Denmark ressa Copenhagen

    If this is indeed true, then it's probably Major or even Critical, since it may break web sites, or make them vulnerable.

  • πŸ‡©πŸ‡°Denmark ressa Copenhagen

    Updating patch file name.

  • Status changed to Closed: works as designed 5 months ago
  • πŸ‡©πŸ‡°Denmark ressa Copenhagen

    Ah, I had a look around for an example, and found this:

    $ grep -A 3 "file-mapping" web/core/composer.json 
                "file-mapping": {
                    "[project-root]/.editorconfig": "assets/scaffold/files/editorconfig",
                    "[project-root]/.gitattributes": "assets/scaffold/files/gitattributes",
                    "[web-root]/.csslintrc": "assets/scaffold/files/csslintrc",
    

    I misunderstood the documentation, and replaced [web-root] with the actual web-root web. After updating to this, all works well:

        "extra": {
            "drupal-scaffold": {
                "locations": {
                    "web-root": "web/"
                },
                "file-mapping": {
                    "[web-root]/.htaccess": {
                        "append": "assets/htaccess-php82.txt"
                    }
                }
            },
    

    Appending also works now after composer install:

    $ composer install
    Installing dependencies from lock file (including require-dev)
    Verifying lock file contents can be installed on current platform.
    Nothing to install, update or remove
    Generating autoload files
    42 packages you are using are looking for funding.
    Use the `composer fund` command to find out more!
    Scaffolding files for drupal/recommended-project:
      - Append to [web-root]/.htaccess from assets/htaccess-php82.txt
    [...]
    
Production build 0.69.0 2024