1 | <?php |
||
2 | |||
3 | /* |
||
4 | * @copyright 2020 Mautic Contributors. All rights reserved |
||
5 | * @author Mautic |
||
6 | * |
||
7 | * @link https://www.mautic.org |
||
8 | * |
||
9 | * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html |
||
10 | */ |
||
11 | |||
12 | namespace Mautic\CoreBundle\Update\Step; |
||
13 | |||
14 | use Mautic\CoreBundle\Helper\AppVersion; |
||
15 | use Mautic\CoreBundle\Helper\PathsHelper; |
||
16 | use Symfony\Component\Console\Helper\ProgressBar; |
||
17 | use Symfony\Component\Console\Input\InputInterface; |
||
18 | use Symfony\Component\Console\Output\OutputInterface; |
||
19 | use Symfony\Component\HttpFoundation\Session\Session; |
||
20 | use Symfony\Component\Translation\TranslatorInterface; |
||
21 | |||
22 | final class FinalizeUpdateStep implements StepInterface |
||
23 | { |
||
24 | /** |
||
25 | * @var TranslatorInterface |
||
26 | */ |
||
27 | private $translator; |
||
28 | |||
29 | /** |
||
30 | * @var PathsHelper |
||
31 | */ |
||
32 | private $pathsHelper; |
||
33 | |||
34 | /** |
||
35 | * @var Session |
||
36 | */ |
||
37 | private $session; |
||
38 | |||
39 | /** |
||
40 | * @var AppVersion |
||
41 | */ |
||
42 | private $appVersion; |
||
43 | |||
44 | public function __construct(TranslatorInterface $translator, PathsHelper $pathsHelper, Session $session, AppVersion $appVersion) |
||
45 | { |
||
46 | $this->translator = $translator; |
||
47 | $this->pathsHelper = $pathsHelper; |
||
48 | $this->session = $session; |
||
49 | $this->appVersion = $appVersion; |
||
50 | } |
||
51 | |||
52 | public function getOrder(): int |
||
53 | { |
||
54 | return 50; |
||
55 | } |
||
56 | |||
57 | public function shouldExecuteInFinalStage(): bool |
||
58 | { |
||
59 | return true; |
||
60 | } |
||
61 | |||
62 | public function execute(ProgressBar $progressBar, InputInterface $input, OutputInterface $output): void |
||
63 | { |
||
64 | $progressBar->setMessage($this->translator->trans('mautic.core.update.step.wrapping_up')); |
||
65 | $progressBar->advance(); |
||
66 | |||
67 | // Clear the cached update data and the download package now that we've updated |
||
68 | @unlink($this->pathsHelper->getRootPath().'/upgrade.php'); |
||
0 ignored issues
–
show
|
|||
69 | @unlink($this->pathsHelper->getCachePath().'/lastUpdateCheck.txt'); |
||
70 | |||
71 | // Update successful |
||
72 | $progressBar->setMessage( |
||
73 | $this->translator->trans('mautic.core.update.update_successful', ['%version%' => $this->appVersion->getVersion()])."\n\n" |
||
74 | ); |
||
75 | $progressBar->finish(); |
||
76 | |||
77 | // Check for a post install message from migrations |
||
78 | if ($postMessage = $this->session->get('post_upgrade_message')) { |
||
79 | $postMessage = strip_tags($postMessage); |
||
80 | $this->session->remove('post_upgrade_message'); |
||
81 | $output->writeln("\n\n<info>$postMessage</info>"); |
||
82 | } |
||
83 | } |
||
84 | } |
||
85 |
If you suppress an error, we recommend checking for the error condition explicitly: