Esempio n. 1
0
require_once __DIR__ . '/app/bootstrap.php';
header('X-Frame-Options: SAMEORIGIN');
header('X-Content-Type-Options: nosniff');
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 8') === false) {
    $xssHeaderValue = '1; mode=block';
} else {
    $xssHeaderValue = '0';
}
header('X-XSS-Protection: ' . $xssHeaderValue);
$status = new \Magento\Update\Status();
$isUpdateInProgress = $status->isUpdateInProgress();
$statusMessage = '';
$statusMessage .= $status->get();
$statusMessage = str_replace("\n", "<br />", $statusMessage);
$queue = new \Magento\Update\Queue();
$pending = !$status->isUpdateInProgress() && !$queue->isEmpty() && !$status->isUpdateError();
if (isset($_SERVER['PATH_INFO']) && !empty($_SERVER['PATH_INFO'])) {
    if ($_SERVER['PATH_INFO'] === '/rollback' && file_exists(MAGENTO_BP . '/var/.update_error.flag')) {
        try {
            $queue->clear();
            $backupInfo = new \Magento\Update\Backup\BackupInfo();
            $backupPaths = $backupInfo->getBackupFilePaths();
            if (isset($backupPaths['error'])) {
                $status->add('WARNING: There is a problem with backup files! Performing rollback from these' . ' files may cause the Magento application to be unstable', \Psr\Log\LogLevel::WARNING);
                foreach ($backupPaths['error'] as $error) {
                    $status->add($error, \Psr\Log\LogLevel::WARNING);
                }
                unset($backupPaths['error']);
            }
            foreach (array_values($backupPaths) as $backupPath) {
                $queue->addJobs(['jobs' => ['name' => $backupPath['type'], 'params' => ['backup_file_name' => $backupPath['filename']]]]);
Esempio n. 2
0
 public function testIsUpdateError()
 {
     $status = new \Magento\Update\Status($this->tmpStatusFilePath, $this->tmpStatusLogFilePath, $this->updateInProgressFlagFilePath, $this->updateErrorFlagFilePath);
     $this->assertFalse($status->isUpdateError());
     $this->assertInstanceOf('Magento\\Update\\Status', $status->setUpdateError());
     $this->assertTrue($status->isUpdateError());
     $this->assertInstanceOf('Magento\\Update\\Status', $status->setUpdateError(false));
     $this->assertFalse($status->isUpdateError());
     $this->assertInstanceOf('Magento\\Update\\Status', $status->setUpdateError(true));
     $this->assertTrue($status->isUpdateError());
 }
<?php

/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
require_once __DIR__ . '/app/bootstrap.php';
$status = new \Magento\Update\Status();
$cronReadinessChecker = new \Magento\Update\CronReadinessCheck();
if (!$cronReadinessChecker->runReadinessCheck()) {
    exit('Cron readiness check failed');
}
if ($status->isUpdateInProgress()) {
    exit('Cron is already in progress...');
}
if ($status->isUpdateError()) {
    exit('There was an error in previous Updater jobs...');
}
$backupDirectory = BACKUP_DIR;
if (!file_exists($backupDirectory)) {
    if (!mkdir($backupDirectory)) {
        $status->add(sprintf('Backup directory "%s" cannot be created.', $backupDirectory));
        exit;
    }
    chmod($backupDirectory, 0770);
}
try {
    $status->setUpdateInProgress();
} catch (\RuntimeException $e) {
    $status->add($e->getMessage());
    exit;