From 12727e20a7f3b0b51b6d0763705835d4da66cea7 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 30 Sep 2013 14:13:28 +0200 Subject: [PATCH] Bump to version a8 --- lib/Alchemy/Phrasea/Core/Version.php | 2 +- lib/classes/patch/3908.php | 132 +++++++++++++++++++++++++++ lib/conf.d/bases_structure.xml | 111 ---------------------- 3 files changed, 133 insertions(+), 112 deletions(-) create mode 100644 lib/classes/patch/3908.php diff --git a/lib/Alchemy/Phrasea/Core/Version.php b/lib/Alchemy/Phrasea/Core/Version.php index 7996a6c825..9afcdadbc7 100644 --- a/lib/Alchemy/Phrasea/Core/Version.php +++ b/lib/Alchemy/Phrasea/Core/Version.php @@ -18,7 +18,7 @@ namespace Alchemy\Phrasea\Core; */ class Version { - protected static $number = '3.9.0.a7'; + protected static $number = '3.9.0.a8'; protected static $name = 'Epanterias'; public static function getNumber() diff --git a/lib/classes/patch/3908.php b/lib/classes/patch/3908.php new file mode 100644 index 0000000000..d05948b352 --- /dev/null +++ b/lib/classes/patch/3908.php @@ -0,0 +1,132 @@ +release; + } + + /** + * {@inheritdoc} + */ + public function require_all_upgrades() + { + return false; + } + + /** + * {@inheritdoc} + */ + public function concern() + { + return $this->concern; + } + + /** + * {@inheritdoc} + */ + public function apply(base $appbox, Application $app) + { + $sql = 'SELECT task_id, active, crashed, name, class, settings FROM task2'; + $stmt = $appbox->get_connection()->prepare($sql); + $stmt->execute(); + $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); + $stmt->closeCursor(); + + foreach ($rs as $row) { + try { + $job = $this->createJob($app, $row['class']); + } catch (\RuntimeException $e) { + continue; + } + + $settings = simplexml_load_string($row['settings']); + $period = $job->getEditor()->getDefaultPeriod(); + if ($settings->period) { + $period = (int) $settings->period; + unset($settings->period); + $row['settings'] = $settings->asXML(); + } + + $task = new Task(); + $task->setCrashed($row['crashed']) + ->setJobId($job->getJobId()) + ->setName($row['name']) + ->setPeriod($period) + ->setSettings($row['settings']) + ->setStatus($row['active'] ? Task::STATUS_STARTED : Task::STATUS_STOPPED); + } + } + + private function createJob(Application $app, $class) + { + switch (strtolower($class)) { + case 'task_period_recordmover': + case 'recordmover': + $name = 'RecordMover'; + break; + case 'task_period_apibridge': + case 'apibridge': + $name = 'Bridge'; + break; + case 'task_period_archive': + case 'archive': + $name = 'Archive'; + break; + case 'task_period_cindexer': + case 'cindexer': + $name = 'PhraseanetIndexer'; + break; + case 'task_period_emptyColl': + case 'emptyColl': + $name = 'EmptyCollection'; + break; + case 'task_period_ftp': + case 'ftp': + $name = 'Ftp'; + break; + case 'task_period_ftppull': + case 'ftppull': + $name = 'FtpPull'; + break; + case 'task_period_subdef': + case 'subdef': + $name = 'Subdefs'; + break; + case 'task_period_test': + case 'test': + $name = 'Null'; + break; + case 'task_period_writemeta': + case 'writemeta': + $name = 'WriteMetadata'; + break; + default: + throw new \RuntimeException(sprintf('Unable to migrate task named %s ', $class)); + } + + return $app['task-manager.job-factory']->create($name); + } +} diff --git a/lib/conf.d/bases_structure.xml b/lib/conf.d/bases_structure.xml index e265525de6..6c96679081 100644 --- a/lib/conf.d/bases_structure.xml +++ b/lib/conf.d/bases_structure.xml @@ -2415,117 +2415,6 @@ InnoDB - - - - task_id - int(11) unsigned - - auto_increment - - - - - usr_id_owner - int(11) unsigned - - - 0 - - - - pid - int(11) unsigned - YES - - - - - - status - enum('stopped','started','starting','stopping','tostart','tostop','manual','torestart') - - - stopped - - ascii_bin - - - crashed - int(2) unsigned - - - 0 - - - - active - int(1) unsigned - - - 0 - - - - name - varchar(100) - - - - - - - last_exec_time - datetime - - - 0000-00-00 00:00:00 - - - - class - varchar(100) - - - - - - - settings - text - - - - - - - completed - tinyint(4) - - - -1 - - - - runner - char(20) - - - -1 - - - - - - PRIMARY - PRIMARY - - task_id - - - - InnoDB -