[BUGFIX] Fix automatic core updater
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Controller / Action / Ajax / AbstractCoreUpdate.php
1 <?php
2 namespace TYPO3\CMS\Install\Controller\Action\Ajax;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * Abstract core update class contains general core update
29 * related methods
30 */
31 abstract class AbstractCoreUpdate extends AbstractAjaxAction {
32
33 /**
34 * @var \TYPO3\CMS\Install\View\JsonView
35 * @inject
36 */
37 protected $view = NULL;
38
39 /**
40 * @var \TYPO3\CMS\Install\Service\CoreUpdateService
41 * @inject
42 */
43 protected $coreUpdateService;
44
45 /**
46 * @var \TYPO3\CMS\Install\Status\StatusUtility
47 * @inject
48 */
49 protected $statusUtility;
50
51 /**
52 * @var \TYPO3\CMS\Install\Service\CoreVersionService
53 * @inject
54 */
55 protected $coreVersionService;
56
57 /**
58 * Initialize the handle action, sets up fluid stuff and assigns default variables.
59 *
60 * @return void
61 * @throws \TYPO3\CMS\Install\Controller\Exception
62 */
63 protected function initializeHandle() {
64 if (!$this->coreUpdateService->isCoreUpdateEnabled()) {
65 throw new \TYPO3\CMS\Install\Controller\Exception(
66 'Core Update disabled in this environment',
67 1381609294
68 );
69 }
70 $this->loadExtLocalconfDatabaseAndExtTables();
71 }
72
73 /**
74 * Find out which version upgrade should be handled. This may
75 * be different depending on whether development or regular release.
76 *
77 * @throws \TYPO3\CMS\Install\Controller\Exception
78 * @return string Version to handle, eg. 6.2.2
79 */
80 protected function getVersionToHandle() {
81 $getVars = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('install');
82 if (!isset($getVars['type'])) {
83 throw new \TYPO3\CMS\Install\Controller\Exception(
84 'Type must be set to either "regular" or "development"',
85 1380975303
86 );
87 }
88 $type = $getVars['type'];
89 if ($type === 'development') {
90 $versionToHandle = $this->coreVersionService->getYoungestPatchDevelopmentRelease();
91 } else {
92 $versionToHandle = $this->coreVersionService->getYoungestPatchRelease();
93 }
94 return $versionToHandle;
95 }
96 }