Skip to content

Commit 6f6ce74

Browse files
authored
Merge pull request #240 from asgrim/fix-phar-overwrite-bug
Fix bug when PHAR is overwritten and EventDispatcher is used
2 parents 5f2b077 + 5d7fa4f commit 6f6ce74

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/Command/SelfUpdateCommand.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,20 @@ public function execute(InputInterface $input, OutputInterface $output): int
148148

149149
$output->writeln('<info>✅ PIE has been upgraded to ' . $latestRelease->tag . '</info>');
150150

151-
return Command::SUCCESS;
151+
$this->exitSuccessfully();
152+
}
153+
154+
/**
155+
* Exit is needed at the moment, as we have an EventDispatcher set on
156+
* the application, which means classes try to get loaded (such as
157+
* {@see \Symfony\Component\Console\Event\ConsoleTerminateEvent}), but
158+
* AFTER we've over-written the PHAR. This results in weird behaviour when
159+
* the class tries to get loaded, as the PHAR content changed. Not an
160+
* ideal approach, need to look into better ways of handling it, maybe
161+
* adding an event listener to overwrite the PHAR *after* the command runs.
162+
*/
163+
private function exitSuccessfully(): never
164+
{
165+
exit(0);
152166
}
153167
}

0 commit comments

Comments
 (0)