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
This commit is contained in:
aynsix
2018-12-26 12:41:09 +04:00
committed by jygaulier
parent 331127d091
commit c20d385292
3 changed files with 70 additions and 4 deletions

View File

@@ -16,7 +16,7 @@ class Version
/**
* @var string
*/
private $number = '4.1.0-alpha.13';
private $number = '4.1.0-alpha.13b';
/**
* @var string

View File

@@ -0,0 +1,64 @@
<?php
/**
* This file is part of Phraseanet
*
* (c) 2005-2016 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Application;
class patch_410alpha13b implements patchInterface
{
/** @var string */
private $release = '4.1.0-alpha.13b';
/** @var array */
private $concern = [base::DATA_BOX];
/**
* {@inheritdoc}
*/
public function get_release()
{
return $this->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;
}
}

View File

@@ -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;