Esempio n. 1
1
 /**
  * Finishes `vp push`
  *
  * @subcommand finish-push
  *
  */
 public function finishPush($args, $assoc_args)
 {
     global $versionPressContainer;
     // Update working copy
     $resetCommand = "git reset --hard";
     $process = VPCommandUtils::exec($resetCommand);
     if (!$process->isSuccessful()) {
         WP_CLI::error("Working directory couldn't be reset");
     }
     // Run synchronization
     /** @var SynchronizationProcess $syncProcess */
     $syncProcess = $versionPressContainer->resolve(VersionPressServices::SYNCHRONIZATION_PROCESS);
     $syncProcess->synchronizeAll();
     vp_flush_regenerable_options();
     vp_disable_maintenance();
     $this->flushRewriteRules();
     vp_enable_maintenance();
 }
Esempio n. 2
0
function _vp_revert($reverterMethod)
{
    global $versionPressContainer;
    vp_verify_nonce('vp_revert');
    vp_check_permissions();
    $commitHash = $_GET['commit'];
    if (!preg_match('/^[0-9a-f]+$/', $commitHash)) {
        exit;
    }
    /** @var Reverter $reverter */
    $reverter = $versionPressContainer->resolve(VersionPressServices::REVERTER);
    vp_enable_maintenance();
    $revertStatus = call_user_func([$reverter, $reverterMethod], [$commitHash]);
    vp_disable_maintenance();
    $adminPage = menu_page_url('versionpress', false);
    if ($revertStatus !== RevertStatus::OK) {
        wp_safe_redirect(add_query_arg('error', $revertStatus, $adminPage));
    } else {
        wp_safe_redirect($adminPage);
    }
    exit;
}
Esempio n. 3
0
function _vp_revert($reverterMethod)
{
    global $versionPressContainer;
    /** @var Reverter $reverter */
    $reverter = $versionPressContainer->resolve(VersionPressServices::REVERTER);
    $commitHash = $_GET['commit'];
    vp_enable_maintenance();
    $revertStatus = call_user_func(array($reverter, $reverterMethod), $commitHash);
    vp_disable_maintenance();
    $adminPage = menu_page_url('versionpress', false);
    if ($revertStatus !== RevertStatus::OK) {
        wp_redirect(add_query_arg('error', $revertStatus, $adminPage));
    } else {
        wp_redirect($adminPage);
    }
}
 /**
  * @param string $reverterMethod
  * @param array $commits
  * @return WP_REST_Response|WP_Error
  */
 public function revertCommits($reverterMethod, $commits)
 {
     vp_enable_maintenance();
     $revertStatus = call_user_func([$this->reverter, $reverterMethod], $commits);
     vp_disable_maintenance();
     if ($revertStatus !== RevertStatus::OK) {
         return $this->getError($revertStatus);
     }
     return new WP_REST_Response(true);
 }
Esempio n. 5
0
 /**
  * Finishes `vp push`
  *
  * @subcommand finish-push
  *
  */
 public function finishPush($args, $assoc_args)
 {
     global $versionPressContainer;
     // Update working copy
     $resetCommand = "git reset --hard";
     $process = VPCommandUtils::exec($resetCommand);
     if (!$process->isSuccessful()) {
         WP_CLI::error("Working directory couldn't be reset");
     }
     // Install current Composer dependencies
     if (file_exists(VP_PROJECT_ROOT . '/composer.json')) {
         $process = VPCommandUtils::exec('composer install', VP_PROJECT_ROOT);
         if ($process->isSuccessful()) {
             WP_CLI::success('Installed Composer dependencies');
         } else {
             WP_CLI::error('Composer dependencies could not be restored.');
         }
     }
     /** @var ActionsDefinitionRepository $actionsDefinitionRepository */
     $actionsDefinitionRepository = $versionPressContainer->resolve(VersionPressServices::ACTIONS_DEFINITION_REPOSITORY);
     $actionsDefinitionRepository->restoreAllDefinitionFilesFromHistory();
     // Run synchronization
     /** @var SynchronizationProcess $syncProcess */
     $syncProcess = $versionPressContainer->resolve(VersionPressServices::SYNCHRONIZATION_PROCESS);
     $syncProcess->synchronizeAll();
     vp_flush_regenerable_options();
     vp_disable_maintenance();
     $this->flushRewriteRules();
     vp_enable_maintenance();
 }
Esempio n. 6
-1
 private function abortInitialization()
 {
     touch(VERSIONPRESS_PLUGIN_DIR . '/.abort-initialization');
     if (VersionPress::isActive()) {
         @unlink(VERSIONPRESS_ACTIVATION_FILE);
     }
     vp_disable_maintenance();
     throw new InitializationAbortedException();
 }