mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-16 14:33:14 +00:00
Slight refactor of set_export to avoid N+1
This commit is contained in:
@@ -68,8 +68,6 @@ class record_exportElement extends record_adapter
|
|||||||
parent::__construct($app, $sbas_id, $record_id);
|
parent::__construct($app, $sbas_id, $record_id);
|
||||||
|
|
||||||
$this->get_actions($remain_hd);
|
$this->get_actions($remain_hd);
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -270,8 +268,7 @@ class record_exportElement extends record_adapter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return array
|
||||||
* @return Array
|
|
||||||
*/
|
*/
|
||||||
public function get_orderable()
|
public function get_orderable()
|
||||||
{
|
{
|
||||||
@@ -279,8 +276,7 @@ class record_exportElement extends record_adapter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return array
|
||||||
* @return Array
|
|
||||||
*/
|
*/
|
||||||
public function get_downloadable()
|
public function get_downloadable()
|
||||||
{
|
{
|
||||||
|
@@ -99,19 +99,20 @@ class set_export extends set_abstract
|
|||||||
} else {
|
} else {
|
||||||
$this->exportName = "Export_" . date("Y-n-d") . '_' . mt_rand(100, 999);
|
$this->exportName = "Export_" . date("Y-n-d") . '_' . mt_rand(100, 999);
|
||||||
|
|
||||||
$tmp_lst = explode(';', $lst);
|
|
||||||
$n = 1;
|
$n = 1;
|
||||||
foreach ($tmp_lst as $basrec) {
|
|
||||||
$basrec = explode('_', $basrec);
|
|
||||||
if (count($basrec) != 2)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
|
$records = new \Alchemy\Phrasea\Record\RecordReferenceCollection();
|
||||||
|
|
||||||
|
foreach (explode(';', $lst) as $basrec) {
|
||||||
try {
|
try {
|
||||||
$record = new record_adapter($this->app, $basrec[0], $basrec[1]);
|
$records[] = \Alchemy\Phrasea\Record\RecordReference::createFromRecordReference($basrec);
|
||||||
} catch (\Exception_Record_AdapterNotFound $e) {
|
} catch (Exception $exception) {
|
||||||
|
// Ignore invalid record references
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($records->toRecords($app->getApplicationBox()) as $record) {
|
||||||
if ($record->isStory()) {
|
if ($record->isStory()) {
|
||||||
foreach ($record->getChildren() as $child_basrec) {
|
foreach ($record->getChildren() as $child_basrec) {
|
||||||
$base_id = $child_basrec->getBaseId();
|
$base_id = $child_basrec->getBaseId();
|
||||||
|
Reference in New Issue
Block a user