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