mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 05:53:13 +00:00
PHRAS-1158_STAMP-CHANGE-COLL
fix : the stamp was not updated when a record changed of collection #time 2h
This commit is contained in:
@@ -116,15 +116,14 @@ class CollectionService
|
||||
*/
|
||||
public function resetStamp(Collection $collection, $record_id = null)
|
||||
{
|
||||
$sql = 'SELECT path, file FROM record r INNER JOIN subdef s USING(record_id)
|
||||
WHERE r.coll_id = :coll_id
|
||||
AND r.type="image" AND s.name IN ("preview", "document")';
|
||||
|
||||
$sql = "SELECT path, file FROM record r INNER JOIN subdef s USING(record_id)\n"
|
||||
. "WHERE r.coll_id = :coll_id\n"
|
||||
. "AND r.type='image' AND s.name IN ('preview', 'document')";
|
||||
|
||||
$params = [':coll_id' => $collection->getCollectionId()];
|
||||
|
||||
if ($record_id) {
|
||||
$sql .= ' AND record_id = :record_id';
|
||||
$sql .= " AND record_id = :record_id";
|
||||
$params[':record_id'] = $record_id;
|
||||
}
|
||||
|
||||
|
@@ -364,10 +364,7 @@ class EditController extends Controller
|
||||
$record->setStatus($newstat);
|
||||
}
|
||||
|
||||
$record
|
||||
->write_metas()
|
||||
->getCollection()
|
||||
->reset_stamp($record->getRecordId());
|
||||
$record->write_metas();
|
||||
|
||||
if ($statbits != '') {
|
||||
$this->getDataboxLogger($databox)
|
||||
|
@@ -42,9 +42,9 @@ class RecordEditSubscriber implements EventSubscriberInterface
|
||||
|
||||
public function onEdit(RecordEdit $event)
|
||||
{
|
||||
$record = $event->getRecord();
|
||||
$recordAdapter = $this->convertToRecordAdapter($event->getRecord());
|
||||
|
||||
$databox = $this->getRecordDatabox($record);
|
||||
$databox = $recordAdapter->getDatabox();
|
||||
|
||||
$metaStructure = $databox->get_meta_structure();
|
||||
$editDateField = false;
|
||||
@@ -55,7 +55,7 @@ class RecordEditSubscriber implements EventSubscriberInterface
|
||||
}
|
||||
|
||||
if ($editDateField instanceof \databox_field) {
|
||||
$this->updateRecord($this->convertToRecordAdapter($record), $editDateField);
|
||||
$this->updateRecord($recordAdapter, $editDateField);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -475,6 +475,10 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
// remove stamp BEFORE changing collection since it uses the collection id :(
|
||||
// todo : change clearStampCache() to be agnostic of collection
|
||||
$this->clearStampCache();
|
||||
|
||||
$sql = "UPDATE record SET moddate = NOW(), coll_id = :coll_id WHERE record_id =:record_id";
|
||||
|
||||
$params = [
|
||||
@@ -993,6 +997,8 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
||||
$this->set_metadata($param, $this->getDatabox());
|
||||
}
|
||||
|
||||
$this->clearStampCache();
|
||||
|
||||
$xml = new DOMDocument();
|
||||
$xml->loadXML($this->app['serializer.caption']->serialize($this->get_caption(), CaptionSerializer::SERIALIZE_XML, true));
|
||||
|
||||
@@ -1292,6 +1298,12 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public function clearStampCache()
|
||||
{
|
||||
$this->getCollection()->reset_stamp($this->getRecordId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[] list of deleted files real paths
|
||||
*/
|
||||
|
Reference in New Issue
Block a user