|
60 | 60 | */
|
61 | 61 | class Flex implements PluginInterface, EventSubscriberInterface
|
62 | 62 | {
|
| 63 | + public static $storedOperations = []; |
| 64 | + |
63 | 65 | /**
|
64 | 66 | * @var Composer
|
65 | 67 | */
|
@@ -129,6 +131,13 @@ class_exists(__NAMESPACE__.str_replace('/', '\\', substr($file, \strlen(__DIR__)
|
129 | 131 | $this->config = $composer->getConfig();
|
130 | 132 | $this->options = $this->initOptions();
|
131 | 133 |
|
| 134 | + // if Flex is being upgraded, the original operations from the original Flex |
| 135 | + // instance are stored in the static property, so we can reuse them now. |
| 136 | + if (property_exists(self::class, 'storedOperations') && self::$storedOperations) { |
| 137 | + $this->operations = self::$storedOperations; |
| 138 | + self::$storedOperations = []; |
| 139 | + } |
| 140 | + |
132 | 141 | $symfonyRequire = preg_replace('/\.x$/', '.x-dev', getenv('SYMFONY_REQUIRE') ?: ($composer->getPackage()->getExtra()['symfony']['require'] ?? ''));
|
133 | 142 |
|
134 | 143 | if ($composer2 = version_compare('2.0.0', PluginInterface::PLUGIN_API_VERSION, '<=')) {
|
@@ -299,6 +308,8 @@ class_exists(__NAMESPACE__.str_replace('/', '\\', substr($file, \strlen(__DIR__)
|
299 | 308 | */
|
300 | 309 | public function deactivate(Composer $composer, IOInterface $io)
|
301 | 310 | {
|
| 311 | + // store operations in case Flex is being upgraded |
| 312 | + self::$storedOperations = $this->operations; |
302 | 313 | self::$activated = false;
|
303 | 314 | }
|
304 | 315 |
|
@@ -550,10 +561,12 @@ function ($value) {
|
550 | 561 | }
|
551 | 562 | }
|
552 | 563 |
|
553 |
| - foreach ($postInstallRecipes as $recipe) { |
554 |
| - $this->configurator->postInstall($recipe, $this->lock, [ |
555 |
| - 'force' => $event instanceof UpdateEvent && $event->force(), |
556 |
| - ]); |
| 564 | + if (method_exists($this->configurator, 'postInstall')) { |
| 565 | + foreach ($postInstallRecipes as $recipe) { |
| 566 | + $this->configurator->postInstall($recipe, $this->lock, [ |
| 567 | + 'force' => $event instanceof UpdateEvent && $event->force(), |
| 568 | + ]); |
| 569 | + } |
557 | 570 | }
|
558 | 571 |
|
559 | 572 | if (null !== $manifest) {
|
|
0 commit comments