示例#1
0
 public function testIsUpdateInProgress()
 {
     $status = new \Magento\Update\Status($this->tmpStatusFilePath, $this->tmpStatusLogFilePath, $this->updateInProgressFlagFilePath);
     $this->assertFalse($status->isUpdateInProgress());
     $this->assertInstanceOf('Magento\\Update\\Status', $status->setUpdateInProgress());
     $this->assertTrue($status->isUpdateInProgress());
     $this->assertInstanceOf('Magento\\Update\\Status', $status->setUpdateInProgress(false));
     $this->assertFalse($status->isUpdateInProgress());
     $this->assertInstanceOf('Magento\\Update\\Status', $status->setUpdateInProgress(true));
     $this->assertTrue($status->isUpdateInProgress());
 }
示例#2
0
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
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);
<?php

/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
require_once __DIR__ . '/app/bootstrap.php';
$status = new \Magento\Update\Status();
$statusMessage = $status->get(10);
$isUpdateInProgress = $status->isUpdateInProgress();
/** TODO: Section below is added for demo purposes */
$status->add("Message #" . rand(1, 1000));
if (!$statusMessage) {
    $statusMessage = 'Please wait for job processing to start.';
}
$statusMessage = str_replace("\n", "<br />", $statusMessage);
//$isUpdateInProgress = (bool)rand(0, 1);
/** TODO: End of section added for demo */
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
    /* Ajax request processing */
    echo json_encode(['statusMessage' => $statusMessage, 'isUpdateInProgress' => $isUpdateInProgress]);
} else {
    include __DIR__ . '/app/code/Magento/Update/view/templates/status.phtml';
}
<?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;