コード例 #1
0
ファイル: index.php プロジェクト: pradeep-wagento/magento2
    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']]]]);
            }
            $status->setUpdateError(false);
        } catch (\Exception $e) {
            $status->setUpdateError(true);
            $status->add('Error in Rollback:' . $e->getMessage(), \Psr\Log\LogLevel::ERROR);
        }
    } elseif ($_SERVER['PATH_INFO'] === '/status') {
        $complete = !$status->isUpdateInProgress() && $queue->isEmpty() && !$status->isUpdateError();
        if ($complete) {
            $status->clear();
        }
        echo json_encode(['statusMessage' => $statusMessage, 'isUpdateInProgress' => $isUpdateInProgress, 'complete' => $complete, 'error' => $status->isUpdateError(), 'pending' => $pending]);
    }
} else {
    if (!file_exists(MAGENTO_BP . '/app/etc/config.php') || !file_exists(MAGENTO_BP . '/app/etc/env.php')) {
        header('Location: ../setup');
        die;
コード例 #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());
 }
コード例 #3
0
        $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;
}
$jobQueue = new \Magento\Update\Queue();
try {
    while (!empty($jobQueue->peek()) && strpos($jobQueue->peek()[\Magento\Update\Queue::KEY_JOB_NAME], 'setup:') === false) {
        $job = $jobQueue->popQueuedJob();
        $status->add(sprintf('Job "%s" has been started', $job));
        try {
            $job->execute();
            $status->add(sprintf('Job "%s" has successfully completed', $job));
        } catch (\Exception $e) {
            $status->setUpdateError();
            $status->add(sprintf('An error occurred while executing job "%s": %s', $job, $e->getMessage()));
            $status->setUpdateInProgress(false);
        }
    }
} catch (\Exception $e) {
    $status->setUpdateError();
    $status->add($e->getMessage());
} finally {
    $status->setUpdateInProgress(false);
}