diff --git a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php index 84a56c0675..3dec948592 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php +++ b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php @@ -1140,7 +1140,8 @@ class V1Controller extends Controller 'original_name' => $record->get_original_name(), 'updated_on' => $record->get_modification_date()->format(DATE_ATOM), 'created_on' => $record->get_creation_date()->format(DATE_ATOM), - 'collection_id' => \phrasea::collFromBas($this->app, $record->get_base_id()), + 'collection_id' => $record->get_collection_id(), + 'base_id' => $record->get_base_id(), 'sha256' => $record->get_sha256(), 'thumbnail' => $this->listEmbeddableMedia($request, $record, $record->get_thumbnail()), 'technical_informations' => $technicalInformation, diff --git a/lib/classes/record/adapter.php b/lib/classes/record/adapter.php index d3c4f6bb52..e6bba9bb83 100644 --- a/lib/classes/record/adapter.php +++ b/lib/classes/record/adapter.php @@ -37,6 +37,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface { protected $xml; protected $base_id; + protected $collection_id; protected $record_id; protected $mime; protected $number; @@ -106,6 +107,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface $this->modification_date = $datas['modification_date']; $this->creation_date = $datas['creation_date']; $this->base_id = $datas['base_id']; + $this->collection_id = $datas['collection_id']; return $this; } catch (\Exception $e) { @@ -124,7 +126,8 @@ class record_adapter implements RecordInterface, cache_cacheableInterface throw new Exception_Record_AdapterNotFound('Record ' . $this->record_id . ' on database ' . $this->databox->get_sbas_id() . ' not found '); } - $this->base_id = (int) phrasea::baseFromColl($this->databox->get_sbas_id(), $row['coll_id'], $this->app); + $this->collection_id = $row['coll_id']; + $this->base_id = (int) phrasea::baseFromColl($this->databox->get_sbas_id(), $this->collection_id, $this->app); $this->creation_date = new DateTime($row['credate']); $this->modification_date = new DateTime($row['moddate']); $this->uuid = $row['uuid']; @@ -136,15 +139,16 @@ class record_adapter implements RecordInterface, cache_cacheableInterface $this->mime = $row['mime']; $datas = [ - 'mime' => $this->mime - , 'sha256' => $this->sha256 - , 'original_name' => $this->original_name - , 'type' => $this->type - , 'grouping' => $this->grouping - , 'uuid' => $this->uuid - , 'modification_date' => $this->modification_date - , 'creation_date' => $this->creation_date - , 'base_id' => $this->base_id + 'mime' => $this->mime, + 'sha256' => $this->sha256, + 'original_name' => $this->original_name, + 'type' => $this->type, + 'grouping' => $this->grouping, + 'uuid' => $this->uuid, + 'modification_date' => $this->modification_date, + 'creation_date' => $this->creation_date, + 'base_id' => $this->base_id, + 'collection_id' => $this->collection_id, ]; $this->set_data_to_cache($datas); @@ -279,6 +283,16 @@ class record_adapter implements RecordInterface, cache_cacheableInterface return $this->base_id; } + /** + * Return collection_id of the record + * + * @return int + */ + public function get_collection_id() + { + return $this->collection_id; + } + /** * Return record collection * @@ -286,7 +300,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface */ public function get_collection() { - return \collection::get_from_base_id($this->app, $this->base_id); + return \collection::get_from_coll_id($this->app, $this->databox, $this->collection_id); } /** @@ -1468,7 +1482,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface $ftodel[] = $stamp; } - $origcoll = phrasea::collFromBas($this->app, $this->get_base_id()); + $origcoll = $this->collection_id; $xml = $this->app['serializer.caption']->serialize($this->get_caption(), CaptionSerializer::SERIALIZE_XML);