Viewing File: /usr/local/cpanel/3rdparty/wpinstaller/src/WpInstaller/Updater.php

<?php
namespace WpInstaller;

class Updater {

    const CONFIG_FILE = 'wp-config.php';

    private $action_logger;
    private $caught_exception;

    function __construct() {
        $this->action_logger = new \Common\ActionLogger();
        $this->finished_updates = false;
        $this->caught_exception = false;
    }

    function __invoke() {
        $result;
        try {
            $this->run();
            $this->action_logger->action_end();
        }
        catch (\Exception $e) {
            $this->action_logger->action_end(false, $e);
            $this->caught_exception = true;
            return [
                'trace'   => $this->action_logger->actions(),
                'success' => false,
           ];
        }

        return [
            'trace'   => $this->action_logger->actions(),
            'success' => $this->finished_updates,
        ];
    }

    function run() {

        // load core
        $this->action_logger->action_start('core_not_installed_check');
        $this->core = new Core(self::CONFIG_FILE);

        if (!$this->core->is_installed()) {
            throw new \Exception("WordPress appears to be not installed at the given install_path");
        }

        // Make sure everything is up to date.
        $this->action_logger->action_start('all_update');
        $this->core->update_installation();

        $this->finished_updates = true;
    }

    function __destruct() {
        if (!$this->finished_updates && !$this->caught_exception) {
            throw new \Exception('exit() was called while applying updates to the installation.');
        }
    }

}

?>
Back to Directory File Manager