From 0f7c03d4cfd7fbcb46966ee0e91a9f5ee4fcd789 Mon Sep 17 00:00:00 2001 From: Ben Thomson Date: Fri, 8 Oct 2021 11:03:54 +0800 Subject: [PATCH] Remove Composer Merge plugin before running Composer commands. Seems to be the sticky wicket that is prevent the Installer from working on shared hosts. --- public/install/api/src/Api.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/public/install/api/src/Api.php b/public/install/api/src/Api.php index 1e4392c..b8f9d69 100644 --- a/public/install/api/src/Api.php +++ b/public/install/api/src/Api.php @@ -380,6 +380,24 @@ public function postExtractWinter() ]); rename($this->rootDir('.temp.sqlite'), $this->workDir('storage/database.sqlite')); } + + // Rewrite composer.json to exclude the Composer Merge plugin, it seems to force the use of Symfony/Process and + // the "proc_open" method which is commonly disabled on shared hosts. + $this->log->notice('Remove Composer Merge plugin from composer.json if found', []); + $composerJson = json_decode(file_get_contents($this->workDir('composer.json')), true); + + if (isset($composerJson['require']['wikimedia/composer-merge-plugin'])) { + $this->log->notice('Found merge plugin in required packages - removing', []); + unset($composerJson['require']['wikimedia/composer-merge-plugin']); + } + if (isset($composerJson['extra']['merge-plugin'])) { + $this->log->notice('Found merge plugin config in "extra" config definition - removing', []); + unset($composerJson['extra']['merge-plugin']); + } + + if (!file_put_contents($this->workDir('composer.json'), json_encode($composerJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES))) { + $this->log->error('Unable to write new Composer config', ['path' => $this->workDir('composer.json')]); + } } /**