-
Notifications
You must be signed in to change notification settings - Fork 27
Description
When adding or deleting patches, paths are not preserved.
This is the test composer.json I am using.
{
"name": "example",
"description": "Example config for a D7 site using composer based build process.",
"repositories": [{
"type": "composer",
"url": "https://packagist.drupal-composer.org"
}],
"require": {
"composer/installers": "~1.0",
"cweagans/composer-patches": "~1.0",
"derhasi/composer-preserve-paths": "0.1.*",
"drupal/drupal": "7.43",
"drupal/views": "~7.0",
"drupal/ctools": "~7.0",
"drupal/memcache": "~7.0",
"drupal/panels": "~7.0"
},
"conflict": {
"drupal/core": "8.*"
},
"scripts": {
"post-create-project-cmd": [
"rm README.md LICENSE .travis.yml phpunit.xml.dist"
]
},
"config": {
"vendor-dir": "vendor"
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"_readme": [
"This is an example comment!"
],
"installer-paths": {
"docroot/": ["type:drupal-core"],
"docroot/sites/all/modules/contrib/{$name}/": ["type:drupal-module"],
"docroot/sites/all/themes/contrib/{$name}/": ["type:drupal-theme"],
"docroot/sites/all/libraries/{$name}/": ["type:drupal-library"],
"docroot/sites/all/drush/{$name}/": ["type:drupal-drush"],
"docroot/profiles/{$name}/": ["type:drupal-profile"]
},
"patches": {
"drupal/drupal": {
"Node access grants should be statically cached": "https://www.drupal.org/files/issues/node_access_grants-static-cache-11.patch",
"Invalid image style URLs should return 404, not 403.": "https://www.drupal.org/files/issues/drupal-image-style-not-found-2211429-4.patch",
"Save and restore css/js/head with block cache.": "https://www.drupal.org/files/issues/d7-block-cache-1460766-34.patch",
"Ignore front end vendor folders to improve directory search performance": "https://www.drupal.org/files/issues/ignore_frontend_folders-2329453-101-7.x.patch"
}
},
"preserve-paths": [
"docroot/robots.txt",
"docroot/.htaccess",
"docroot/sites/all/modules/contrib",
"docroot/sites/all/themes/contrib",
"docroot/sites/all/libraries",
"docroot/sites/all/drush",
"docroot/sites/default/settings.php",
"docroot/sites/default/files"
]
}
}
After installing, I am making changes in robots.txt which I want to preserve.
Adding or updating any packages works fine and preserves the changes.
Now If I add/remove a patch and do composer update
, all the changes are gone.
I did a short debugging, and here is what I think is happening:
For cleanly applying patches composer-patches plugin deletes package files (in this case docroot) by responding to ScriptEvents::PRE_INSTALL_CMD
event which happens to be before the ScriptEvents::PRE_PACKAGE_INSTALL
/ ScriptEvents::PRE_PACKAGE_UPDATE
events in event loop - where composer-preserve-paths plugin backs up the files. So when composer-preserve-paths gets chance to backup files, they are already removed, so nothing to backup and hence restore.