-
Notifications
You must be signed in to change notification settings - Fork 394
Is it possible to apply a custom drupal/core .htaccess patch after composer update? How? #1135
Comments
The only thing I can think of that might get this to work is adding a post-update-cmd, but that feels hacky.
|
I'm guessing that doesn't work because the .htaccess file is moved out of the /docroot/core/ folder (where composer downloads all of Drupal core to) and into /docroot instead. This one of the the drupal "scaffolding" files that the drupal-composer/drupal-scaffold project handles for you. I'm not sure if there's a way to do this w/ composer patches for that reason. That said, updates to drupal core are pretty infrequent and you could revert the changes in git pretty easily after the update, right? |
@bkosborne Yeah, this happens pretty infrequently so we could definitely revert the changes manually. That being said, I work on a team so it just adds a bit more overhead to keep track of. Stuff like this really needs to be automated otherwise it's likely to get missed at some point down the road. Is there a way to apply the patch via the |
Agreed it adds some overhead, but it's always been the case with Drupal core updates that you have to manually check any overrides you made to scaffolding files like robots.txt and .htaccess. That said, being able to automate it is a great idea anyway. I'm not sure I can help you though, sorry. |
Something like this might work:
|
I couldn't find any way to patch the .htaccess file. The docs in patches/README are very misleading on how to apply patches. As mentioned here, you cannot patch .htaccess because it doesn't get moved to the docroot until drupal-scaffold runs. So trying to patch it in The only "solution" I have found is to just add
This at least keeps your changes intact during updates, but if Drupal core ever changed its .htaccess file you'd need to manually merge that with your patched version. I posted here: drupal-composer/drupal-scaffold#45 to suggest that drupal-scaffold add a better way to patch files, or at least runs a "post scaffold" script that we could hook into. |
I think @mike-potter is correct, there isn't currently any way to do this. You must commit the modified file. Documentation for this has been added in #1157. This should be pursued in drupal-composer/drupal-scaffold#45. |
For others having this issue, I did find a fix from the drupal-scaffold process. You can run a
|
Here's the bash script I ended up creating at
I then call my patches in the
Here's what my
@grasmash I'm going to try and add this to the documentation somewhere but do you think it's worth adding a version of my shell script above to the project? |
May be needed with no prefix option for generating patch . |
This appears to be the root of the issue. When you run "composer update drupal/core" and attempt to patch the .htaccess file, that file doesn't exist yet as Composer actually copies the .htaccess file from Put together, you end up with something like this in the composer.json file:
Then the patches/core_htaccess.patch file looks like this:
When you next run |
After I applied the post-drupal-scaffold-cmd patch method above, a co-worker pointed out the append feature in drupal scaffold. So, if you just need to add come rules to the end of the .htaccess this may be an easier method than managing a patch on an gitignored file.
|
I know this is an old post, but my Googling hasn't revealed any answers about the syntax of a htaccess.patch how much of
Is needed if you wanted to append
at the end of your .htaccess file? My composer.json sees my patch, and the scaffold command runs fine, but I get an error saying the text is garbage, and I know that is because I don't have the correct syntax. I've never built a .htaccess patch before. Any help would be appreciated. |
For appending, the text file contains only the text that gets added. So in your case the file would just have
and in your composer.json
|
We have a situation where we need to apply a custom local htaccess patch after running composer update. The patch applies some custom url redirects but doesn't seem to run as expected when I add it to our
drupal/core
patches in composer.json.Here is my patch:
Here is the composer.json drupal/core patch lines:
If I add -vvv to my $
composer update
command I'm seeing the following error:I'm assuming this has to do with how the drupal-scaffolding gets built but I'm unsure how to solve this issue given the BLT ecosystem.
Seems like a similar issue:
#608
The text was updated successfully, but these errors were encountered: