From c9fef92ea56d824638a7a053301cb1c508907d59 Mon Sep 17 00:00:00 2001 From: aynsix Date: Wed, 20 Dec 2023 17:48:53 +0300 Subject: [PATCH] fix --- lib/Alchemy/Phrasea/Command/Record/BuildSubdefs.php | 4 ++-- lib/classes/record/adapter.php | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/Alchemy/Phrasea/Command/Record/BuildSubdefs.php b/lib/Alchemy/Phrasea/Command/Record/BuildSubdefs.php index 2afd7c28e7..0f89028593 100644 --- a/lib/Alchemy/Phrasea/Command/Record/BuildSubdefs.php +++ b/lib/Alchemy/Phrasea/Command/Record/BuildSubdefs.php @@ -401,7 +401,7 @@ protected function doExecute(InputInterface $input, OutputInterface $output) /** @var media_subdef $subdef */ $subdefsDeleted = []; - foreach ($record->get_subdefs() as $subdef) { + foreach ($record->get_subdefs_from_db() as $subdef) { $name = $subdef->get_name(); if($name == "document") { continue; @@ -597,7 +597,7 @@ protected function getSQL() $sql .= "GROUP BY r.`record_id`"; if(!$this->scheduled && !$this->all) { - $sql .= "\nHAVING `exists` != `waited`"; + $sql .= "\nHAVING (`exists` IS NULL OR `exists` != `waited`)"; } $sql .= "\nORDER BY r.`record_id` " . ($this->reverse ? "DESC" : "ASC"); diff --git a/lib/classes/record/adapter.php b/lib/classes/record/adapter.php index 32659e42df..0af62920d6 100644 --- a/lib/classes/record/adapter.php +++ b/lib/classes/record/adapter.php @@ -745,6 +745,19 @@ public function get_subdefs() return $this->subdefs; } + /** + * @return media_subdef[] + */ + public function get_subdefs_from_db() + { + $subdefs = []; + foreach ($this->getMediaSubdefRepository()->findByRecordIdsAndNames([$this->getRecordId()]) as $subdef) { + $subdefs[$subdef->get_name()] = $subdef; + } + + return $subdefs; + } + /** * @return string[] */