From c20d3852928b73bcbba6d6738d401ba0a7c2d5ab Mon Sep 17 00:00:00 2001 From: aynsix <35221835+aynsix@users.noreply.github.com> Date: Wed, 26 Dec 2018 12:41:09 +0400 Subject: [PATCH] PHRAS-2329 Port to master : log_doc error when move a record between collections (#2867) * port PHRAS-2317 fix: wrong coll_id in log_docs when move collection * update --- lib/Alchemy/Phrasea/Core/Version.php | 2 +- lib/classes/patch/410alpha13b.php | 64 ++++++++++++++++++++++++++++ lib/classes/record/adapter.php | 8 ++-- 3 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 lib/classes/patch/410alpha13b.php diff --git a/lib/Alchemy/Phrasea/Core/Version.php b/lib/Alchemy/Phrasea/Core/Version.php index 9d397d453e..860c3b2679 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.13'; + private $number = '4.1.0-alpha.13b'; /** * @var string diff --git a/lib/classes/patch/410alpha13b.php b/lib/classes/patch/410alpha13b.php new file mode 100644 index 0000000000..3846f8bf19 --- /dev/null +++ b/lib/classes/patch/410alpha13b.php @@ -0,0 +1,64 @@ +release; + } + + /** + * {@inheritdoc} + */ + public function getDoctrineMigrations() + { + return []; + } + + /** + * {@inheritdoc} + */ + public function require_all_upgrades() + { + return false; + } + + /** + * {@inheritdoc} + */ + public function concern() + { + return $this->concern; + } + + /** + * {@inheritdoc} + */ + public function apply(base $databox, Application $app) + { + $sql = "UPDATE `log_docs` SET `coll_id`=`final` WHERE `action`='collection'"; + $databox->get_connection()->prepare($sql)->execute(); + + return true; + } +} diff --git a/lib/classes/record/adapter.php b/lib/classes/record/adapter.php index e49904424a..c4045d9fc5 100644 --- a/lib/classes/record/adapter.php +++ b/lib/classes/record/adapter.php @@ -530,11 +530,12 @@ class record_adapter implements RecordInterface, cache_cacheableInterface } $coll_id_from = $this->getCollectionId(); + $coll_id_to = $collection->get_coll_id(); $sql = "UPDATE record SET moddate = NOW(), coll_id = :coll_id WHERE record_id =:record_id"; $params = [ - ':coll_id' => $collection->get_coll_id(), + ':coll_id' => $coll_id_to, ':record_id' => $this->getRecordId(), ]; @@ -543,12 +544,13 @@ class record_adapter implements RecordInterface, cache_cacheableInterface $stmt->closeCursor(); $this->base_id = $collection->get_base_id(); + $this->collection_id = $coll_id_to; + + $this->delete_data_from_cache(); $this->app['phraseanet.logger']($this->getDatabox()) ->log($this, Session_Logger::EVENT_MOVE, $collection->get_coll_id(), '', $coll_id_from); - $this->delete_data_from_cache(); - $this->dispatch(RecordEvents::COLLECTION_CHANGED, new CollectionChangedEvent($this)); return $this;