composer-patches: Applying Patches Drupal8: [ErrorException] Array to string conversion
I just updated core to 8.3.1 and updated modules and everything and ran composer update multiple times to get all things updated.
Then after few updates, I started to get this error.
Exception trace:
() at /var/www/drupalvm/vendor/cweagans/composer-patches/src/Patches.php:296
Composer\Util\ErrorHandler::handle() at /var/www/drupalvm/vendor/cweagans/composer-patches/src/Patches.php:296
cweagans\Composer\Patches->postInstall() at n/a:n/a
call_user_func() at phar:///usr/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:171
Composer\EventDispatcher\EventDispatcher->doDispatch() at phar:///usr/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:116
Composer\EventDispatcher\EventDispatcher->dispatchPackageEvent() at phar:///usr/bin/composer/src/Composer/Installer.php:605
Composer\Installer->doInstall() at phar:///usr/bin/composer/src/Composer/Installer.php:223
Composer\Installer->run() at phar:///usr/bin/composer/src/Composer/Command/UpdateCommand.php:158
Composer\Command\UpdateCommand->execute() at phar:///usr/bin/composer/vendor/symfony/console/Command/Command.php:267
Symfony\Component\Console\Command\Command->run() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:846
Symfony\Component\Console\Application->doRunCommand() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:191
Symfony\Component\Console\Application->doRun() at phar:///usr/bin/composer/src/Composer/Console/Application.php:227
Composer\Console\Application->doRun() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:122
Symfony\Component\Console\Application->run() at phar:///usr/bin/composer/src/Composer/Console/Application.php:100
Composer\Console\Application->run() at phar:///usr/bin/composer/bin/composer:54
require() at /usr/bin/composer:24
I then added some debugging print_r’s to Patches.php.
I printed content of that $url variable inside the patching loop @ line 288 of Patches.php.
And this is what I got:
Array
(
[0] => https://www.drupal.org/files/issues/core_path-alias_manager-language_fallback_and_test-2802403-45-D8.patch
[1] => https://www.drupal.org/files/issues/core_path-alias_manager-language_fallback_and_test-2802403-45-D8.patch
)
It seems that those patches do get parsed twice, it doesn’t matter what files I try to patch, the result is always the same.
Any idea on what might be causing this behavior?
Here’s my composer.json with some privacy edits.
{
"name": "drupal-composer/drupal-project",
"description": "Project template for Drupal 8 projects with composer",
"type": "project",
"license": "GPL-2.0+",
"authors": [
{
"name": "",
"role": ""
}
],
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
},
{
"type": "vcs",
"url": "git@bitbucket.org:XXX/XXXX"
}
],
"require": {
"composer/installers": "^1.2",
"drupal-composer/drupal-scaffold": "^2.2",
"cweagans/composer-patches": "~1.0",
"drupal/core": "~8.0",
"drush/drush": "~8.0",
"drupal/console": "~1.0",
"drupal/admin_toolbar": "^1.0",
"drupal/better_normalizers": "dev-1.x",
"drupal/blazy": "^1.0",
"drupal/breakpoint_js_settings": "^1.0",
"drupal/config_update": "^1.0",
"drupal/crop": "1.2",
"drupal/ctools": "^3.0",
"drupal/dropzonejs": "1.0-alpha6",
"drupal/entity": "^1.0",
"drupal/entity_browser": "1.0-rc2",
"drupal/entity_reference_revisions": "^1.0",
"drupal/field_group": "^1.0",
"drupal/focal_point": "^1.0",
"drupal/google_analytics": "^2.0",
"drupal/inline_entity_form": "^1.0",
"drupal/libraries": "dev-3.x",
"drupal/linkit": "4.1",
"drupal/media_entity": "1.6",
"drupal/media_entity_instagram": "1.2",
"drupal/media_entity_image": "^1.0",
"drupal/media_entity_slideshow": "^1.0",
"drupal/media_entity_twitter": "^1.0",
"drupal/media_expire": "^1.0",
"drupal/metatag": "1.x-dev",
"drupal/paragraphs": "1.0",
"drupal/pathauto": "^1.0@RC",
"drupal/scheduler": "^1.0",
"drupal/simple_sitemap": "2.x-dev",
"drupal/slick": "^1.0",
"drupal/slick_media": "^1.0",
"drupal/token": "^1.0",
"drupal/video_embed_field": "^1.0",
"drupal/views_load_more": "dev-1.x",
"drupal/coffee": "^1.0@beta",
"zurb/foundation": "^6.3",
"drupal/module_filter": "^3.0",
"drupal/ckeditor_media_embed": "^1.0",
"drupal/ckeditor_font": "^1.0",
"drupal/search_api": "^1.0@beta",
"drupal/entity_embed": "^1.0@beta",
"drupal/file_browser": "^1.0@alpha",
"drupal/devel": "^1.0@RC",
"drupal/iframe": "^1.6",
"drupal/shield": "^1.0",
"mekanismi/ckeditor_responsive_foundation": "dev-master",
"drush/config-extra": "^1.0",
"drupal/fpa": "2.x-dev",
"drupal/adminimal_theme": "^1.3",
"drupal/twig_xdebug": "^1.0",
"drupal/menu_block_current_language": "^1.0@RC",
"drupal/viewsreference": "^1.0@alpha",
"ajgl/breakpoint-twig-extension": "^0.3.0",
"drupal/google_tag": "1.x-dev",
"drupal/rules": "3.x-dev",
"drupal/contact_block": "^1.3",
"drupal/contact_storage": "^1.0@beta",
"drupal/swiftmailer": "^1.0@beta",
"drupal/filefield_paths": "^1.0@beta",
"drupal/redirect": "^1.0@alpha",
"drupal/eu_cookie_compliance": "^1.0@beta",
"drupal/stage_file_proxy": "^1.0@alpha",
"drupal/shortcutperrole": "^1.0@RC",
"drupal/roleassign": "^1.0@alpha",
"drupal/cacheflush": "^1.0@alpha",
"drupal/webform": "^5.0@beta",
"drupal/config_ignore": "2.0-rc2",
"drupal/config_filter": "1.x-dev",
"drupal/config_split": "^1.0@beta",
"drupal/captcha": "^1.0@beta",
"drupal/webform_views": "5.x-dev",
"drupal/webform_layout_container": "^1.0",
"drupal/reroute_email": "^1.0@beta",
"drupal/mailgun": "1.x-dev",
"drupal/composer_manager": "^1.0@RC",
"drupal/hook_post_action": "1.x-dev"
},
"require-dev": {
"behat/mink": "~1.7",
"behat/mink-goutte-driver": "~1.2",
"jcalderonzumba/gastonjs": "~1.0.2",
"jcalderonzumba/mink-phantomjs-driver": "~0.3.1",
"mikey179/vfsStream": "~1.2",
"phpunit/phpunit": "~4.8",
"symfony/css-selector": "~2.8"
},
"conflict": {
"drupal/drupal": "*"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"classmap": [
"scripts/composer/ScriptHandler.php"
]
},
"scripts": {
"drupal-scaffold": "DrupalComposer\\DrupalScaffold\\Plugin::scaffold",
"pre-install-cmd": [
"DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
],
"pre-update-cmd": [
"DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
],
"post-install-cmd": [
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
],
"post-update-cmd": [
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
]
},
"extra": {
"installer-paths": {
"web/core": ["type:drupal-core"],
"web/libraries/{$name}": ["type:drupal-library"],
"web/modules/contrib/{$name}": ["type:drupal-module"],
"web/profiles/contrib/{$name}": ["type:drupal-profile"],
"web/themes/contrib/{$name}": ["type:drupal-theme"],
"drush/contrib/{$name}": ["type:drupal-drush"]
},
"patches": {
"drupal/paragraphs": {
"IEF Simple Widget not working in paragraphs with preview mode": "https://www.drupal.org/files/issues/ief_simple_widget_not-2722097-36.patch",
"Saving problem in preview mode with IEF items": "https://www.drupal.org/files/issues/saving_problem_in-2804377-2.patch"
},
"drupal/dropzonejs": {
"DropzneJS is cleared on every Ajax response": "https://www.drupal.org/files/issues/dropznejs_is_cleared_on-2827120-11_0.patch",
"Improved MultiStep selection display (DropZone Widget)": "https://www.drupal.org/files/issues/improved_multistep-2823670-14.patch"
},
"drupal/linkit": {
"Missing ckeditor plugin schema": "https://www.drupal.org/files/issues/missing_ckeditor_plugin-2812889-2.patch"
},
"drupal/media_entity": {
"Make the label form element non-required in the entity form": "https://www.drupal.org/files/issues/2813685-21.patch"
},
"drupal/media_entity_instagram": {
"Make posts responsive": "https://www.drupal.org/files/issues/make_posts_responsive-2807735-13.patch"
},
"drupal/filefield_paths": {
"Call to undefined method BaseFieldDefinition::getThirdPartySettings()": "https://www.drupal.org/files/issues/ignore_base_fields.patch"
},
"drupal/mailgun": {
"Mailgun api version user configurable": "https://www.drupal.org/files/issues/configurable_api_version-2865386.patch"
},
"drupal/core" : {
"Link Field Causes Pages to 404 with Bad Route Caching on Multilingual Sites": "https://www.drupal.org/files/issues/core_path-alias_manager-language_fallback_and_test-2802403-45-D8.patch"
},
"drupal/crop": {
"Crop-modulen installDefaultConfig pois": "https://bitbucket.org/!api/2.0/xxxxx/xxxx.patch"
}
}
}
}
I think I was updating Paragraphs to 1.1, Entity Browser to 1.0, Dropzonejs to 1.0-alpha6 and Linkit to 4.3 if that has anything to do with anything.
Thanks for any assistance, our updates are stuck because of this, so any help is appreciated.
/ Janne
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 17 (5 by maintainers)
Commits related to this issue
- Hacky work-around for https://github.com/cweagans/composer-patches/issues/123 . — committed to rgristroph/composer-patches by rgristroph 7 years ago
- PPossible fix for https://github.com/cweagans/composer-patches/issues/123 — committed to pczerkas/composer-patches by pczerkas 2 years ago
Hi guys on last release 1.6.4 I have experimented this issue and happened when in project composer.json file I have declared a patch that also was declared in a dependency composer.json file. There was two same patch covered by a Drupal contrib module in it composer.json file which we previously declared on our main project composer.json file and when that happened this error display and cannot apply any patch.
I just quick solved by removing our main project composer.json file patches declaration and keep the contrib modules lines which will end in the patched modules we expect. Maybe there is a way to handle this more smoothly but I don’t know enough of composer-patches source code so leave this report for your evaluation.
Thanks for your help.
I haven’t looked into it too far, but my guess is that one of your dependencies is adding the same patch that you’re trying to add. Your composer.json finished successfully for me locally, but I had to remove your bitbucket repo and mekanismi/ckeditor_responsive_foundation from the requirements to get it to finish. Consider starting with the composer.json in mekanismi/ckeditor_responsive_foundation to see if it defines the same patch you have in your root composer.json.
Nice one @rgristroph !
I did some researching and found out that this occurs only if vendor folder exists. If I delete vendor and run composer install, everything works as expected. That’s why it worked on our deployments, even if we couldn’t run install locally.
Is there any way for me to patch this plugin automatically? Or do I have to setup separate repo for this fix?
Cheers, Janne
Hmm… I added some code to get past this error on my local drupalvm. Like so:
With this added to 2 methods in Patches.php I got packages updated. Although, those patches are doubled on every patch I try to apply.
I then thought that my local composer / DrupalVM is messed up and tested with our stage environment. Didn’t get any errors, but those merged patches that I’ve removed from my composer.json are still present and composer tries to apply them. So I get quite some errors.
For example:
Those patches are definitely NOT in active composer.json.
Everything seems to be working, so I’m not really sure what’s happening here.
Cheers,
Janne