diff --git a/lib/Alchemy/Phrasea/Core/Version.php b/lib/Alchemy/Phrasea/Core/Version.php index c209691c0b..5f488cdd5a 100644 --- a/lib/Alchemy/Phrasea/Core/Version.php +++ b/lib/Alchemy/Phrasea/Core/Version.php @@ -16,7 +16,7 @@ class Version /** * @var string */ - private $number = '4.1.0-alpha.19a'; + private $number = '4.1.0-alpha.20a'; /** * @var string diff --git a/lib/classes/patch/410alpha20a.php b/lib/classes/patch/410alpha20a.php new file mode 100644 index 0000000000..ff02a35c96 --- /dev/null +++ b/lib/classes/patch/410alpha20a.php @@ -0,0 +1,111 @@ +release; + } + + /** + * {@inheritdoc} + */ + public function concern() + { + return $this->concern; + } + + /** + * {@inheritdoc} + */ + public function require_all_upgrades() + { + return false; + } + + /** + * {@inheritdoc} + */ + public function getDoctrineMigrations() + { + return []; + } + + /** + * {@inheritdoc} + */ + public function apply(base $databox, Application $app) + { + // fix the Longitude value + + $sql = 'SELECT id, record_id, name, value FROM technical_datas WHERE trim(name) = "LongitudeRef" '; + $stmt = $databox->get_connection()->prepare($sql); + $stmt->execute(); + $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); + $stmt->closeCursor(); + + foreach ($rs as $row) { + if (trim($row['value']) === 'W' ) { + $sql = 'UPDATE technical_datas SET value = CONCAT("-", value) WHERE trim(name) = "Longitude" AND record_id =:record_id'; + $stmt = $databox->get_connection()->prepare($sql); + $stmt->execute([':record_id' => $row['record_id']]); + } + + $sqlDelete = 'DELETE FROM technical_datas WHERE id =:id'; + + $stmt1 = $databox->get_connection()->prepare($sqlDelete); + $stmt1->execute([':id' => $row['id']]); + $stmt1->closeCursor(); + } + + $stmt->closeCursor(); + + // fix the Latitude value + + $sql = 'SELECT id, record_id, name, value FROM technical_datas WHERE trim(name) = "LatitudeRef" '; + $stmt = $databox->get_connection()->prepare($sql); + $stmt->execute(); + $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); + $stmt->closeCursor(); + + foreach ($rs as $row) { + if (trim($row['value']) === 'S' ) { + $sql = 'UPDATE technical_datas SET value = CONCAT("-", value) WHERE trim(name) = "Latitude" AND record_id =:record_id'; + $stmt = $databox->get_connection()->prepare($sql); + $stmt->execute([':record_id' => $row['record_id']]); + } + + $sqlDelete = 'DELETE FROM technical_datas WHERE id =:id'; + + $stmt1 = $databox->get_connection()->prepare($sqlDelete); + $stmt1->execute([':id' => $row['id']]); + $stmt1->closeCursor(); + } + + $stmt->closeCursor(); + + return true; + } +}