From 9fd58b522face7f72f1f6f00cef34902f3670277 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Tue, 22 Dec 2015 11:45:04 -0500 Subject: [PATCH] Added option to skip steps in upgrade process. --- .../VuFind/Controller/UpgradeController.php | 21 +++++++++++++++---- .../templates/upgrade/getsourcedir.phtml | 14 +++++++++++-- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/module/VuFind/src/VuFind/Controller/UpgradeController.php b/module/VuFind/src/VuFind/Controller/UpgradeController.php index 989a818a008..73ac35a77a6 100644 --- a/module/VuFind/src/VuFind/Controller/UpgradeController.php +++ b/module/VuFind/src/VuFind/Controller/UpgradeController.php @@ -604,6 +604,19 @@ class UpgradeController extends AbstractBase return $this->createViewModel(); } + /** + * Make sure we only skip the actions the user wants us to. + * + * @return void + */ + protected function processSkipParam() + { + $skip = $this->params()->fromPost('skip', []); + foreach (['config', 'database', 'metadata'] as $action) { + $this->cookie->{$action . 'Okay'} = in_array($action, (array)$skip); + } + } + /** * Prompt the user for a source version (to upgrade from 2.x). * @@ -628,6 +641,7 @@ class UpgradeController extends AbstractBase $this->cookie->sourceDir = realpath(APPLICATION_PATH); // Clear out request to avoid infinite loop: $this->getRequest()->getPost()->set('sourceversion', ''); + $this->processSkipParam(); return $this->forwardTo('Upgrade', 'Home'); } } @@ -665,19 +679,19 @@ class UpgradeController extends AbstractBase } // Now make sure we have a configuration file ready: - if (!isset($this->cookie->configOkay)) { + if (!isset($this->cookie->configOkay) || !$this->cookie->configOkay) { return $this->redirect()->toRoute('upgrade-fixconfig'); } // Now make sure the database is up to date: - if (!isset($this->cookie->databaseOkay)) { + if (!isset($this->cookie->databaseOkay) || !$this->cookie->databaseOkay) { return $this->redirect()->toRoute('upgrade-fixdatabase'); } // Check for missing metadata in the resource table; note that we do a // redirect rather than a forward here so that a submit button clicked // in the database action doesn't cause the metadata action to also submit! - if (!isset($this->cookie->metadataOkay)) { + if (!isset($this->cookie->metadataOkay) || !$this->cookie->metadataOkay) { return $this->redirect()->toRoute('upgrade-fixmetadata'); } @@ -718,4 +732,3 @@ class UpgradeController extends AbstractBase return $this->forwardTo('Upgrade', 'Home'); } } - diff --git a/themes/bootstrap3/templates/upgrade/getsourcedir.phtml b/themes/bootstrap3/templates/upgrade/getsourcedir.phtml index ce9c4925d61..e0bf64956b2 100644 --- a/themes/bootstrap3/templates/upgrade/getsourcedir.phtml +++ b/themes/bootstrap3/templates/upgrade/getsourcedir.phtml @@ -12,8 +12,18 @@ <form class="form-inline" method="post" action="<?=$this->url('upgrade-getsourcedir')?>"> <input type="text" name="sourcedir" /> <input class="btn btn-default" type="submit" /> </form> +<hr /> <h3>Option 2: Upgrade from VuFind 2.x</h3> -<p>Please enter the version number you are upgrading from (e.g. 2.0.1):</p> <form class="form-inline" method="post" action="<?=$this->url('upgrade-getsourceversion')?>"> - <input type="text" name="sourceversion" /> <input class="btn btn-default" type="submit" /> + <p> + Please enter the version number you are upgrading from (e.g. 2.0.1): + <input type="text" name="sourceversion" /> + </p> + <p>Options:<br /> + <? foreach (['config' => 'Configuration', 'database' => 'Database Structure', 'metadata' => 'Stored Metadata'] as $key => $value): ?> + <input type="checkbox" name="skip[]" id="skip-<?=$this->escapeHtmlAttr($key)?>" value="<?=$this->escapeHtmlAttr($key)?>" /> + <label for="skip-<?=$this->escapeHtmlAttr($key)?>">Skip <?=$this->escapeHtml($value); ?> Upgrade</label><br /> + <? endforeach; ?> + </p> + <input class="btn btn-default" type="submit" /> </form> -- GitLab