From f01c9a672c56d6a8e08b83b09d01db6a9bafbd7e Mon Sep 17 00:00:00 2001 From: Aina Sitraka <35221835+aynsix@users.noreply.github.com> Date: Fri, 8 Dec 2023 01:49:19 +0300 Subject: [PATCH] stop to try to write metadata on story (#4433) --- .../Subscriber/RecordSubscriber.php | 86 ++++++++++--------- 1 file changed, 45 insertions(+), 41 deletions(-) diff --git a/lib/Alchemy/Phrasea/WorkerManager/Subscriber/RecordSubscriber.php b/lib/Alchemy/Phrasea/WorkerManager/Subscriber/RecordSubscriber.php index 781cb550a4..6e1b78a8f6 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Subscriber/RecordSubscriber.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Subscriber/RecordSubscriber.php @@ -162,50 +162,54 @@ public function onRecordsWriteMeta(RecordsWriteMetaEvent $event) $databox = $this->getApplicationBox()->get_databox($databoxId); $record = $databox->get_record($recordId); - $type = $record->getType(); - $subdefGroupe = $record->getDatabox()->get_subdef_structure()->getSubdefGroup($record->getType()); + // do not try to write meta on non story record + if (!$record->isStory()) { + $type = $record->getType(); - if ($subdefGroupe !== null) { - $toWritemetaOriginalDocument = $subdefGroupe->toWritemetaOriginalDocument(); - } else { - $toWritemetaOriginalDocument = true; - } + $subdefGroupe = $record->getDatabox()->get_subdef_structure()->getSubdefGroup($record->getType()); - foreach ($mediaSubdefs as $subdef) { - // check subdefmetadatarequired from the subview setup in admin - // check if we want to write meta in this mime type - if (in_array(trim($subdef->get_mime()), $acceptedMimeTypes) && - ( - ($subdef->get_name() == 'document' && $toWritemetaOriginalDocument) || - $this->isSubdefMetadataUpdateRequired($databox, $type, $subdef->get_name()) - ) - ) { - $payload = [ - 'message_type' => MessagePublisher::WRITE_METADATAS_TYPE, - 'payload' => [ - 'recordId' => $recordId, - 'databoxId' => $databoxId, - 'subdefName' => $subdef->get_name() - ] - ]; - if ($subdef->is_physically_present()) { - $this->messagePublisher->publishMessage($payload, MessagePublisher::WRITE_METADATAS_TYPE); - } - else { - $logMessage = sprintf('Subdef "%s" is not physically present! to be passed in the retry q of "%s" ! payload >>> %s', - $subdef->get_name(), - MessagePublisher::WRITE_METADATAS_TYPE, - json_encode($payload) - ); - $this->messagePublisher->pushLog($logMessage); - - $this->messagePublisher->publishRetryMessage( - $payload, - MessagePublisher::WRITE_METADATAS_TYPE, - 2, - 'Subdef is not physically present!' - ); + if ($subdefGroupe !== null) { + $toWritemetaOriginalDocument = $subdefGroupe->toWritemetaOriginalDocument(); + } else { + $toWritemetaOriginalDocument = true; + } + + foreach ($mediaSubdefs as $subdef) { + // check subdefmetadatarequired from the subview setup in admin + // check if we want to write meta in this mime type + if (in_array(trim($subdef->get_mime()), $acceptedMimeTypes) && + ( + ($subdef->get_name() == 'document' && $toWritemetaOriginalDocument) || + $this->isSubdefMetadataUpdateRequired($databox, $type, $subdef->get_name()) + ) + ) { + $payload = [ + 'message_type' => MessagePublisher::WRITE_METADATAS_TYPE, + 'payload' => [ + 'recordId' => $recordId, + 'databoxId' => $databoxId, + 'subdefName' => $subdef->get_name() + ] + ]; + if ($subdef->is_physically_present()) { + $this->messagePublisher->publishMessage($payload, MessagePublisher::WRITE_METADATAS_TYPE); + } + else { + $logMessage = sprintf('Subdef "%s" is not physically present! to be passed in the retry q of "%s" ! payload >>> %s', + $subdef->get_name(), + MessagePublisher::WRITE_METADATAS_TYPE, + json_encode($payload) + ); + $this->messagePublisher->pushLog($logMessage); + + $this->messagePublisher->publishRetryMessage( + $payload, + MessagePublisher::WRITE_METADATAS_TYPE, + 2, + 'Subdef is not physically present!' + ); + } } } }