80 $this->downloadBaseUri = $this->coreVersionService->getDownloadBaseUri();
89 $coreUpdateDisabled = getenv(
'TYPO3_DISABLE_CORE_UPDATER') ?: (getenv(
'REDIRECT_TYPO3_DISABLE_CORE_UPDATER') ?: FALSE);
90 return !$coreUpdateDisabled;
99 return PATH_site .
'typo3_src';
129 public function updateVersionMatrix() {
132 $this->coreVersionService->updateVersionMatrix();
136 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
137 $message->setTitle(
'Version matrix could not be fetched from get.typo3.org');
138 $message->setMessage(
139 'Current version specification could not be fetched from http://get.typo3.org/json.' 140 .
' This is probably a network issue, please fix it.' 142 $this->messages = array($message);
154 public function checkPreConditions($version) {
159 $statusUtility = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\StatusUtility');
163 $folderStructureFacade = $this->objectManager->get(
'TYPO3\\CMS\\Install\\FolderStructure\\DefaultFactory')->getStructure();
164 $folderStructureErrors = $statusUtility->filterBySeverity($folderStructureFacade->getStatus(),
'error');
165 $folderStructureWarnings = $statusUtility->filterBySeverity($folderStructureFacade->getStatus(),
'warning');
166 if (count($folderStructureErrors) > 0 || count($folderStructureWarnings) > 0) {
169 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
170 $message->setTitle(
'Automatic TYPO3 CMS core update not possible: Folder structure has errors or warnings');
171 $message->setMessage(
172 'To perform an update, the folder structure of this TYPO3 CMS instance must' 173 .
' stick to the conventions, or the update process could lead to unexpected' 174 .
' results and may be hazardous to your system' 180 if (TYPO3_OS ===
'WIN') {
183 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
184 $message->setTitle(
'Automatic TYPO3 CMS core update not possible: Update not supported on Windows OS');
190 $file = PATH_site . uniqid(
'install-core-update-test-', TRUE);
195 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
196 $message->setTitle(
'Automatic TYPO3 CMS core update not possible: No write access to document root');
197 $message->setMessage(
'Could not write a file in path "' . PATH_site .
'"!');
205 $coreLocation = @realPath($this->symlinkToCoreFiles .
'/../');
206 $file = $coreLocation .
'/' . uniqid(
'install-core-update-test-', TRUE);
211 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
212 $message->setTitle(
'Automatic TYPO3 CMS core update not possible: No write access to TYPO3 CMS core location');
213 $message->setMessage(
214 'New TYPO3 CMS core should be installed in "' . $coreLocation .
'", but this directory is not writable!' 223 if ($success && !$this->coreVersionService->isInstalledVersionAReleasedVersion()) {
226 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
227 $message->setTitle(
'Automatic TYPO3 CMS core update not possible: You are running a development version of TYPO3');
228 $message->setMessage(
229 'Your current version is specified as ' . $this->coreVersionService->getInstalledVersion() .
'.' 230 .
' This is a development version and can not be updated automatically. If this is a "git"' 231 .
' checkout, please update using git directly.' 246 public function downloadVersion($version) {
252 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\NoticeStatus');
253 $message->setTitle(
'Skipped download of TYPO3 CMS core. A core source directory already exists in destination path. Using this instead.');
256 $downloadUri = $this->downloadBaseUri . $version;
259 if (@file_exists($fileLocation)) {
262 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
270 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
271 $message->setTitle(
'Download not successful');
274 $fileStoreResult = file_put_contents($fileLocation, $fileContent);
275 if (!$fileStoreResult) {
278 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
279 $message->setTitle(
'Unable to store download content');
282 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\OkStatus');
283 $message->setTitle(
'TYPO3 CMS core download finished');
299 public function verifyFileChecksum($version) {
305 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\WarningStatus');
306 $message->setTitle(
'Verifying existing TYPO3 CMS core checksum is not possible');
310 $expectedChecksum = $this->coreVersionService->getTarGzSha1OfVersion($version);
312 if (!file_exists($fileLocation)) {
315 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
316 $message->setTitle(
'Downloaded TYPO3 CMS core not found');
319 $actualChecksum = sha1_file($fileLocation);
320 if ($actualChecksum !== $expectedChecksum) {
323 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
324 $message->setTitle(
'New TYPO3 CMS core checksum mismatch');
325 $message->setMessage(
326 'The official TYPO3 CMS version system on https://get.typo3.org expects a sha1 checksum of ' 327 . $expectedChecksum .
' from the content of the downloaded new TYPO3 CMS core version ' . $version .
'.' 328 .
' The actual checksum is ' . $actualChecksum .
'. The update is stopped. This may be a' 329 .
' failed download, an attack, or an issue with the typo3.org infrastructure.' 333 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\OkStatus');
334 $message->setTitle(
'Checksum verified');
349 public function unpackVersion($version) {
355 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\NoticeStatus');
356 $message->setTitle(
'Unpacking TYPO3 CMS core files skipped');
359 $fileLocation = $this->downloadTargetPath . $version .
'.tar.gz';
361 if (!@is_file($fileLocation)) {
364 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
365 $message->setTitle(
'Downloaded TYPO3 CMS core not found');
367 } elseif (@file_exists($this->downloadTargetPath .
'typo3_src-' . $version)) {
370 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
374 $unpackCommand =
'tar xf ' . escapeshellarg($fileLocation) .
' -C ' . escapeshellarg($this->downloadTargetPath) .
' 2>&1';
375 exec($unpackCommand, $output, $errorCode);
379 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
380 $message->setTitle(
'Unpacking TYPO3 CMS core not successful');
383 $removePackedFileResult = unlink($fileLocation);
384 if (!$removePackedFileResult) {
387 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
388 $message->setTitle(
'Removing packed TYPO3 CMS core not successful');
391 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\OkStatus');
392 $message->setTitle(
'Unpacking TYPO3 CMS core successful');
408 public function moveVersion($version) {
414 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\NoticeStatus');
415 $message->setTitle(
'Moving TYPO3 CMS core files skipped');
418 $downloadedCoreLocation = $this->downloadTargetPath .
'typo3_src-' . $version;
419 $newCoreLocation = @realPath($this->symlinkToCoreFiles .
'/../') .
'/typo3_src-' . $version;
421 if (!@is_dir($downloadedCoreLocation)) {
424 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
425 $message->setTitle(
'Unpacked TYPO3 CMS core not found');
428 $moveResult = rename($downloadedCoreLocation, $newCoreLocation);
432 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
433 $message->setTitle(
'Moving TYPO3 CMS core to ' . $newCoreLocation .
' failed');
436 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\OkStatus');
437 $message->setTitle(
'Moved TYPO3 CMS core to final location');
453 public function activateVersion($version) {
454 $newCoreLocation = @realPath($this->symlinkToCoreFiles .
'/../') .
'/typo3_src-' . $version;
459 if (!is_dir($newCoreLocation)) {
462 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
463 $message->setTitle(
'New TYPO3 CMS core not found');
465 } elseif (!is_link($this->symlinkToCoreFiles)) {
468 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
469 $message->setTitle(
'TYPO3 CMS core source directory (typo3_src) is not a link');
473 $unlinkResult = unlink($this->symlinkToCoreFiles);
474 if (!$unlinkResult) {
477 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
478 $message->setTitle(
'Removing old symlink failed');
481 if (!$isCurrentCoreSymlinkAbsolute) {
484 $symlinkResult = symlink($newCoreLocation, $this->symlinkToCoreFiles);
485 if ($symlinkResult) {
490 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
491 $message->setTitle(
'Linking new TYPO3 CMS core failed');
508 return $this->downloadTargetPath . $version .
'.tar.gz';
518 $sourcePath = explode(DIRECTORY_SEPARATOR, rtrim(PATH_site, DIRECTORY_SEPARATOR));
519 $targetPath = explode(DIRECTORY_SEPARATOR, rtrim($absolutePath, DIRECTORY_SEPARATOR));
520 while (count($sourcePath) && count($targetPath) && $sourcePath[0] === $targetPath[0]) {
521 array_shift($sourcePath);
522 array_shift($targetPath);
524 return str_pad(
'', count($sourcePath) * 3,
'..' . DIRECTORY_SEPARATOR) . implode(DIRECTORY_SEPARATOR, $targetPath);
535 $newCoreLocation = @realPath($this->symlinkToCoreFiles .
'/../') .
'/typo3_src-' . $version;
536 return @is_dir($newCoreLocation);
getRelativePath($absolutePath)
static mkdir_deep($directory, $deepDirectory='')
static clearAllActive($fileAbsPath=NULL)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
static getUrl($url, $includeHeader=0, $requestHeaders=FALSE, &$report=NULL)
getDownloadTarGzTargetPath($version)
setDownloadTargetPath($downloadTargetPath)
checkCoreFilesAvailable($version)
discoverCurrentCoreLocation()
static isAbsolutePath($path)
static stripPathSitePrefix($path)