From 306516f83874f402f0d02f0fb5585c76c81ad032 Mon Sep 17 00:00:00 2001 From: Gaspard Jacobson <52928254+gjacobjn@users.noreply.github.com> Date: Thu, 5 Sep 2024 22:56:01 +0200 Subject: [PATCH 01/12] Bump rabbitMQ version to 3.8.34 (#4546) Bump rabbitMQ version to 3.8.34. Issue with Centos 9 on previous version. --- docker-compose.datastores.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.datastores.yml b/docker-compose.datastores.yml index 47c7563e17..a1daa13cec 100644 --- a/docker-compose.datastores.yml +++ b/docker-compose.datastores.yml @@ -21,7 +21,7 @@ services: - internal rabbitmq: - image: rabbitmq:3.6.16-management + image: rabbitmq:3.8.34-management profiles: ["rabbitmq"] restart: on-failure hostname: $RABBITMQ_HOSTNAME @@ -55,4 +55,4 @@ services: volumes: - ${PHRASEANET_ELASTICSEARCH_DIR}:/usr/share/elasticsearch/data networks: - - internal \ No newline at end of file + - internal From 53d13938ff31f987ab2e0f7295e11cbaab110b6f Mon Sep 17 00:00:00 2001 From: Aina Sitraka <35221835+aynsix@users.noreply.github.com> Date: Fri, 6 Sep 2024 09:42:44 +0300 Subject: [PATCH 02/12] PHRAS-4090:Prod - expose-cli - publication - publication description is Nok (#4536) * fix expose publication description * fix submit twice on expose cli --- .../web/prod/WorkZone/ExposeEdit.html.twig | 16 +++--- .../web/prod/WorkZone/ExposeNew.html.twig | 52 +++++++++++-------- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/templates/web/prod/WorkZone/ExposeEdit.html.twig b/templates/web/prod/WorkZone/ExposeEdit.html.twig index 5d5043fade..edb9388c28 100644 --- a/templates/web/prod/WorkZone/ExposeEdit.html.twig +++ b/templates/web/prod/WorkZone/ExposeEdit.html.twig @@ -28,22 +28,22 @@
- - + +
- +
- +
- +
{% if publication.parent.id %} {% set parentId = publication.parent.id %} @@ -60,7 +60,7 @@ {% if publication.capabilities.operator %}
- + {% set nbProfile = publication.profile|length %} + +
- +
- +
- +
- - +
- - +
- - +
-
- +
- +
-
+
{#

{{ 'prod:expose:publication:Advanced setting' | trans }}

#}
+
diff --git a/templates/web/developers/application_form.html.twig b/templates/web/developers/application_form.html.twig index c1ec6cb8bf..9b543afea0 100644 --- a/templates/web/developers/application_form.html.twig +++ b/templates/web/developers/application_form.html.twig @@ -123,5 +123,6 @@
+ {% endblock %} diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Root/AccountTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Root/AccountTest.php index 4f42595d3c..0aed6b756f 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Root/AccountTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Root/AccountTest.php @@ -384,6 +384,7 @@ public function testUpdateAccount() $app = $this->getApplication(); $client = $this->getClient(); $bases = $notifs = []; + $randomValue = $this->setSessionFormToken('userAccount'); foreach ($app->getDataboxes() as $databox) { foreach ($databox->get_collections() as $collection) { @@ -424,7 +425,8 @@ public function testUpdateAccount() 'form_retryFTP' => '', 'notifications' => $notifs, 'form_defaultdataFTP' => ['document', 'preview', 'caption'], - 'mail_notifications' => '1' + 'mail_notifications' => '1', + 'userAccount_token' => $randomValue ]); $response = $client->getResponse(); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Root/DevelopersTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Root/DevelopersTest.php index f3fbc55fb5..4f81818540 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Root/DevelopersTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Root/DevelopersTest.php @@ -39,6 +39,8 @@ public function testDisplayformApp() */ public function testPostNewAppInvalidArguments() { + $randomValue = $this->setSessionFormToken('newApplication'); + $crawler = self::$DI['client']->request('POST', '/developers/application/', [ 'type' => ApiApplication::WEB_TYPE, 'name' => '', @@ -46,7 +48,8 @@ public function testPostNewAppInvalidArguments() 'website' => 'my.website.com', 'callback' => 'my.callback.com', 'scheme-website' => 'http://', - 'scheme-callback' => 'http://' + 'scheme-callback' => 'http://', + 'newApplication_token' => $randomValue ]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); @@ -63,6 +66,7 @@ public function testPostNewApp() { $apps = self::$DI['app']['repo.api-applications']->findByCreator(self::$DI['user']); $nbApp = count($apps); + $randomValue = $this->setSessionFormToken('newApplication'); self::$DI['client']->request('POST', '/developers/application/', [ 'type' => ApiApplication::WEB_TYPE, @@ -71,7 +75,8 @@ public function testPostNewApp() 'website' => 'my.website.com', 'callback' => 'my.callback.com', 'scheme-website' => 'http://', - 'scheme-callback' => 'http://' + 'scheme-callback' => 'http://', + 'newApplication_token' => $randomValue ]); $apps = self::$DI['app']['repo.api-applications']->findByCreator(self::$DI['user']); From 47371bb2aa9cd29d97638902653b04e2f8f436a8 Mon Sep 17 00:00:00 2001 From: Aina Sitraka <35221835+aynsix@users.noreply.github.com> Date: Wed, 23 Oct 2024 20:57:10 +0300 Subject: [PATCH 07/12] fix (#4555) --- .../Phrasea/Core/Configuration/DisplaySettingService.php | 4 ++++ templates/web/prod/index.html.twig | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Alchemy/Phrasea/Core/Configuration/DisplaySettingService.php b/lib/Alchemy/Phrasea/Core/Configuration/DisplaySettingService.php index 11987a9d5c..99c4ff90cd 100644 --- a/lib/Alchemy/Phrasea/Core/Configuration/DisplaySettingService.php +++ b/lib/Alchemy/Phrasea/Core/Configuration/DisplaySettingService.php @@ -98,6 +98,10 @@ public function getUserSetting(User $user, $name, $default = null) return array_key_exists($name, $this->usersSettings) ? $this->usersSettings[$name] : $default; } + if ($name == 'start_page_query') { + return htmlentities($user->getSettings()->get($name)->getValue()); + } + return $user->getSettings()->get($name)->getValue(); } diff --git a/templates/web/prod/index.html.twig b/templates/web/prod/index.html.twig index 519c46f298..5a39d59250 100644 --- a/templates/web/prod/index.html.twig +++ b/templates/web/prod/index.html.twig @@ -986,7 +986,7 @@ {{ 'Aide' | trans }} - +
From 3fa25670878adc1180723d62bda0c556ec0eed9f Mon Sep 17 00:00:00 2001 From: Aina Sitraka <35221835+aynsix@users.noreply.github.com> Date: Wed, 23 Oct 2024 21:16:30 +0300 Subject: [PATCH 08/12] PHRAS-4088: improving Job ack in workerRunningJob (#4535) * improve workerrunningjob finished * subdefcreation mark as finished when file exist --- .../WorkerRunningJobRepository.php | 14 ++-- .../AdminConfigurationController.php | 76 +++++++++++++++++-- .../Provider/AlchemyWorkerServiceProvider.php | 2 +- .../Worker/CreateRecordWorker.php | 23 ++---- .../Worker/DeleteRecordWorker.php | 9 +-- .../Worker/DownloadAsyncWorker.php | 15 ++-- .../WorkerManager/Worker/EditRecordWorker.php | 12 +-- .../WorkerManager/Worker/ExportMailWorker.php | 19 +++-- .../Worker/ExposeUploadWorker.php | 2 +- .../WorkerManager/Worker/FtpWorker.php | 14 +--- .../Worker/PopulateIndexWorker.php | 10 +-- .../Worker/ShareBasketWorker.php | 26 +++++-- .../Worker/SubdefCreationWorker.php | 2 +- .../WorkerManager/Worker/SubtitleWorker.php | 10 ++- .../WorkerManager/Worker/WebhookWorker.php | 9 +-- .../Worker/WriteMetadatasWorker.php | 8 +- 16 files changed, 137 insertions(+), 114 deletions(-) diff --git a/lib/Alchemy/Phrasea/Model/Repositories/WorkerRunningJobRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/WorkerRunningJobRepository.php index cd32204602..3e0b281c59 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/WorkerRunningJobRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/WorkerRunningJobRepository.php @@ -328,14 +328,16 @@ private function releaseMutex(int $recordMutexId) * mark a job a "finished" * nb : after a long job, connection may be lost so we reconnect. * But sometimes (?) a first commit fails (due to reconnect ?), while the second one is ok. - * So here we try 2 times, just in case... + * So here we try 4 times, just in case... * * @param int $workerRunningJobId + * @param MessagePublisher $messagePublisher + * @param $jobType * @param null $info */ - public function markFinished(int $workerRunningJobId, $info = null) + public function markFinished(int $workerRunningJobId, MessagePublisher $messagePublisher, $jobType, $info = null) { - for($tryout=1; $tryout<=2; $tryout++) { + for($wait = 2, $tryout=1; $tryout<=4; $tryout++) { try { $this->reconnect(); $cnx = $this->getEntityManager()->getConnection()->getWrappedConnection(); @@ -356,8 +358,10 @@ public function markFinished(int $workerRunningJobId, $info = null) throw new Exception(sprintf("updating WorkerRunningJob should return 1 row affected, got %s", $a)); } catch (Exception $e) { - if($tryout < 2) { - sleep(1); // retry in 1 sec + if($tryout < 4) { + $messagePublisher->pushLog(sprintf("failed updating WorkerRunningJob to finished with id=%d for %s, attempt %d", $workerRunningJobId, $jobType, $tryout)); + sleep($wait); // retry after more sec + $wait *= 2; } } } diff --git a/lib/Alchemy/Phrasea/WorkerManager/Controller/AdminConfigurationController.php b/lib/Alchemy/Phrasea/WorkerManager/Controller/AdminConfigurationController.php index 5f4e2684c1..38f3a6a8b0 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Controller/AdminConfigurationController.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Controller/AdminConfigurationController.php @@ -5,6 +5,7 @@ use Alchemy\Phrasea\Application as PhraseaApplication; use Alchemy\Phrasea\Application\Helper\DataboxLoggerAware; use Alchemy\Phrasea\Controller\Controller; +use Alchemy\Phrasea\Filesystem\FilesystemService; use Alchemy\Phrasea\Model\Entities\WorkerRunningJob; use Alchemy\Phrasea\Model\Repositories\WorkerRunningJobRepository; use Alchemy\Phrasea\Plugin\Exception\JsonValidationException; @@ -224,12 +225,34 @@ public function changeStatusAction(Request $request, $workerId) /** @var WorkerRunningJob $workerRunningJob */ $workerRunningJob = $repoWorker->find($workerId); - - $workerRunningJob->setStatus($request->request->get('status')); + $subdefOK = false; $finishedDate = new \DateTime('now'); - if($request->request->get('finished') == '1') { - $workerRunningJob->setFinished($finishedDate)->setFlock(null); + if ($workerRunningJob->getWork() == 'subdefCreation') { + try { + $databox = $this->findDataboxById($workerRunningJob->getDataboxId()); + $record = $databox->get_record($workerRunningJob->getRecordId()); + if ($record->has_subdef($workerRunningJob->getWorkOn()) ) { + $filePathToCheck = $record->get_subdef($workerRunningJob->getWorkOn())->getRealPath(); + if ($this->getFileSystem()->exists($filePathToCheck)) { + // the subdefinition exist + // so mark as finished + $subdefOK = true; + $workerRunningJob->setStatus(WorkerRunningJob::FINISHED); + $workerRunningJob->setFinished($finishedDate)->setFlock(null); + } + } + } catch (\Exception $e) { + } + } + + if (!$subdefOK || $workerRunningJob->getWork() != 'subdefCreation') { + $workerRunningJob->setStatus($request->request->get('status')); + + + if($request->request->get('finished') == '1') { + $workerRunningJob->setFinished($finishedDate)->setFlock(null); + } } $em = $repoWorker->getEntityManager(); @@ -259,14 +282,48 @@ public function doChangeStatusToCanceledAction(PhraseaApplication $app, Request { /** @var WorkerRunningJobRepository $repoWorker */ $repoWorker = $this->app['repo.worker-running-job']; + $finishedDate = new \DateTime('now'); + $em = $repoWorker->getEntityManager(); + $workerRunningJobs = $repoWorker->getRunningSinceCreated($request->request->get('hour'), ['subdefCreation', 'writeMetadatas']); + $workerRunningJobsForOnlySubdefcreation = $repoWorker->getRunningSinceCreated($request->request->get('hour'), ['subdefCreation']); + // treat the subdefinition case + /** @var WorkerRunningJob $ws */ + foreach ($workerRunningJobsForOnlySubdefcreation as $ws) { + $subdefOK = false; + try { + $databox = $this->findDataboxById($ws->getDataboxId()); + $record = $databox->get_record($ws->getRecordId()); + if ($record->has_subdef($ws->getWorkOn()) ) { + $filePathToCheck = $record->get_subdef($ws->getWorkOn())->getRealPath(); + if ($this->getFileSystem()->exists($filePathToCheck)) { + // the subdefinition exist + // so mark as finished + $subdefOK = true; + $ws->setStatus(WorkerRunningJob::FINISHED); + $ws->setFinished($finishedDate)->setFlock(null); + } + } + + } catch (\Exception $e) { + } + + if (!$subdefOK) { + $ws->setStatus(WorkerRunningJob::INTERRUPT); + $ws->setFinished($finishedDate)->setFlock(null); + } + $em->persist($ws); + } + $em->flush(); + + // treat all the rest case $repoWorker->updateStatusRunningToCanceledSinceCreated($request->request->get('hour')); - $finishedDate = new \DateTime('now'); + // "log docs" the subdefCreation and writeMetadatas action /** @var WorkerRunningJob $workerRunningJob */ foreach ($workerRunningJobs as $workerRunningJob) { - $this->updateLogDocs($workerRunningJob, 'canceled', $finishedDate); + $this->updateLogDocs($workerRunningJob, $workerRunningJob->getStatus(), $finishedDate); } return $this->app->json(['success' => true]); @@ -791,4 +848,11 @@ private function getUrlGenerator() return $this->app['url_generator']; } + /** + * @return FilesystemService + */ + private function getFileSystem() + { + return $this->app['phraseanet.filesystem']; + } } diff --git a/lib/Alchemy/Phrasea/WorkerManager/Provider/AlchemyWorkerServiceProvider.php b/lib/Alchemy/Phrasea/WorkerManager/Provider/AlchemyWorkerServiceProvider.php index 71aba39dfe..c947fd6023 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Provider/AlchemyWorkerServiceProvider.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Provider/AlchemyWorkerServiceProvider.php @@ -159,7 +159,7 @@ public function register(Application $app) })); $app['alchemy_worker.type_based_worker_resolver']->addFactory(MessagePublisher::SUBTITLE_TYPE, new CallableWorkerFactory(function () use ($app) { - return (new SubtitleWorker($app['repo.worker-running-job'], $app['conf'], new LazyLocator($app, 'phraseanet.appbox'), $app['alchemy_worker.logger'], $app['dispatcher'])) + return (new SubtitleWorker($app['repo.worker-running-job'], $app['conf'], new LazyLocator($app, 'phraseanet.appbox'), $app['alchemy_worker.logger'], $app['dispatcher'], $app['alchemy_worker.message.publisher'])) ->setFileSystemLocator(new LazyLocator($app, 'filesystem')) ->setTemporaryFileSystemLocator(new LazyLocator($app, 'temporary-filesystem')); })); diff --git a/lib/Alchemy/Phrasea/WorkerManager/Worker/CreateRecordWorker.php b/lib/Alchemy/Phrasea/WorkerManager/Worker/CreateRecordWorker.php index 03847d2fa2..18168332e2 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Worker/CreateRecordWorker.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Worker/CreateRecordWorker.php @@ -137,24 +137,6 @@ public function process(array $payload) return; } - if ($workerRunningJob != null) { - $em->beginTransaction(); - try { - $workerRunningJob - ->setStatus(WorkerRunningJob::FINISHED) - ->setFinished(new \DateTime('now')) - ; - - $em->persist($workerRunningJob); - - $em->flush(); - $em->commit(); - } catch (\Exception $e) { - $em->rollback(); - } - - } - $lazaretSession = new LazaretSession(); $userRepository = $this->getUserRepository(); @@ -257,6 +239,11 @@ public function process(array $payload) ] ] ); + + if ($workerRunningJob != null) { + $this->repoWorkerJob->markFinished($workerRunningJob->getId(), $this->messagePublisher, MessagePublisher::CREATE_RECORD_TYPE); + } + } /** diff --git a/lib/Alchemy/Phrasea/WorkerManager/Worker/DeleteRecordWorker.php b/lib/Alchemy/Phrasea/WorkerManager/Worker/DeleteRecordWorker.php index ad1fc0a492..59a2184baa 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Worker/DeleteRecordWorker.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Worker/DeleteRecordWorker.php @@ -69,14 +69,7 @@ public function process(array $payload) // tell that the delete is finished if ($workerRunningJob != null) { - $workerRunningJob - ->setStatus(WorkerRunningJob::FINISHED) - ->setFinished(new \DateTime('now')) - ; - - $em->persist($workerRunningJob); - - $em->flush(); + $this->repoWorker->markFinished($workerRunningJob->getId(), $this->messagePublisher, MessagePublisher::DELETE_RECORD_TYPE); } } } diff --git a/lib/Alchemy/Phrasea/WorkerManager/Worker/DownloadAsyncWorker.php b/lib/Alchemy/Phrasea/WorkerManager/Worker/DownloadAsyncWorker.php index e567530ac9..35270ab176 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Worker/DownloadAsyncWorker.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Worker/DownloadAsyncWorker.php @@ -385,15 +385,7 @@ public function process(array $payload) ); if ($workerRunningJob != null) { - $this->repoWorkerJob->reconnect(); - $workerRunningJob - ->setStatus(WorkerRunningJob::FINISHED) - ->setFinished(new \DateTime('now')) - ; - - $em->persist($workerRunningJob); - - $em->flush(); + $this->repoWorkerJob->markFinished($workerRunningJob->getId(), $this->getMessagePublisher(),MessagePublisher::DOWNLOAD_ASYNC_TYPE); } sleep(1); @@ -436,6 +428,11 @@ private function getWorkerRunningJobRepository() return $this->app['repo.worker-running-job']; } + private function getMessagePublisher() + { + return $this->app['alchemy_worker.message.publisher']; + } + private function cellRefFromColumnAndRow(int $col, int $row = null) { $r = Coordinate::stringFromColumnIndex($col); diff --git a/lib/Alchemy/Phrasea/WorkerManager/Worker/EditRecordWorker.php b/lib/Alchemy/Phrasea/WorkerManager/Worker/EditRecordWorker.php index 0997204cf5..0886615a61 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Worker/EditRecordWorker.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Worker/EditRecordWorker.php @@ -200,17 +200,7 @@ public function process(array $payload) ); // tell that we have finished to work on edit - $this->repoWorker->reconnect(); - $em->getConnection()->beginTransaction(); - try { - $workerRunningJob->setStatus(WorkerRunningJob::FINISHED); - $workerRunningJob->setFinished(new \DateTime('now')); - $em->persist($workerRunningJob); - $em->flush(); - $em->commit(); - } catch (\Exception $e) { - $em->rollback(); - } + $this->repoWorker->markFinished($workerRunningJob->getId(), $this->messagePublisher, MessagePublisher::EDIT_RECORD_TYPE); $this->messagePublisher->pushLog(sprintf("record edited databoxname=%s databoxid=%d recordid=%d", $databox->get_viewname(), $payload['databoxId'], $payload['record_id'])); } diff --git a/lib/Alchemy/Phrasea/WorkerManager/Worker/ExportMailWorker.php b/lib/Alchemy/Phrasea/WorkerManager/Worker/ExportMailWorker.php index 0e33106341..a836277085 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Worker/ExportMailWorker.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Worker/ExportMailWorker.php @@ -216,16 +216,7 @@ public function process(array $payload) } if ($workerRunningJob != null) { - $this->repoWorkerJob->reconnect(); - $workerRunningJob - ->setWorkOn(implode(',', $deliverEmails)) - ->setStatus(WorkerRunningJob::FINISHED) - ->setFinished(new \DateTime('now')) - ; - - $em->persist($workerRunningJob); - - $em->flush(); + $this->repoWorkerJob->markFinished($workerRunningJob->getId(), $this->getMessagePublisher(), MessagePublisher::EXPORT_MAIL_TYPE); } sleep(30); @@ -250,4 +241,12 @@ private function getWorkerRunningJobRepository() { return $this->app['repo.worker-running-job']; } + + /** + * @return MessagePublisher + */ + private function getMessagePublisher() + { + return $this->app['alchemy_worker.message.publisher']; + } } diff --git a/lib/Alchemy/Phrasea/WorkerManager/Worker/ExposeUploadWorker.php b/lib/Alchemy/Phrasea/WorkerManager/Worker/ExposeUploadWorker.php index 1050e8df37..2bab163278 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Worker/ExposeUploadWorker.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Worker/ExposeUploadWorker.php @@ -373,7 +373,7 @@ public function process(array $payload) } // tell that the upload is finished - $this->finishedJob($workerRunningJob, $em); + $this->repoWorker->markFinished($workerRunningJob->getId(), $this->messagePublisher, MessagePublisher::EXPOSE_UPLOAD_TYPE); } private function getClientAnnotationProfile(Client $exposeClient, $publicationId) diff --git a/lib/Alchemy/Phrasea/WorkerManager/Worker/FtpWorker.php b/lib/Alchemy/Phrasea/WorkerManager/Worker/FtpWorker.php index 6db13c3bd9..af710f16ad 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Worker/FtpWorker.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Worker/FtpWorker.php @@ -355,18 +355,7 @@ private function doExport(FtpExport $export, array $payload) if (!$processError && $workerRunningJob) { // tell that we have finished to work on this file - $this->repoWorker->reconnect(); - $em->beginTransaction(); - try { - $workerRunningJob->setStatus(WorkerRunningJob::FINISHED); - $workerRunningJob->setFinished(new \DateTime('now')); - $em->persist($workerRunningJob); - $em->flush(); - $em->commit(); - } - catch (Exception $e) { - $em->rollback(); - } + $this->repoWorker->markFinished($workerRunningJob->getId(), $this->getMessagePublisher(), MessagePublisher::FTP_TYPE); } else { // if there is an error $count = isset($payload['count']) ? $payload['count'] + 1 : 2 ; @@ -537,5 +526,4 @@ private function getMessagePublisher() { return $this->app['alchemy_worker.message.publisher']; } - } diff --git a/lib/Alchemy/Phrasea/WorkerManager/Worker/PopulateIndexWorker.php b/lib/Alchemy/Phrasea/WorkerManager/Worker/PopulateIndexWorker.php index 465599fae9..98e45a44fa 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Worker/PopulateIndexWorker.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Worker/PopulateIndexWorker.php @@ -145,15 +145,7 @@ public function process(array $payload) // tell that the populate is finished if ($workerRunningJob != null) { - $this->repoWorker->reconnect(); - $workerRunningJob - ->setStatus(WorkerRunningJob::FINISHED) - ->setFinished(new \DateTime('now')) - ; - - $em->persist($workerRunningJob); - - $em->flush(); + $this->repoWorker->markFinished($workerRunningJob->getId(), $this->messagePublisher, MessagePublisher::POPULATE_INDEX_TYPE); } } diff --git a/lib/Alchemy/Phrasea/WorkerManager/Worker/ShareBasketWorker.php b/lib/Alchemy/Phrasea/WorkerManager/Worker/ShareBasketWorker.php index 3fc10e136a..e8d23471f8 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Worker/ShareBasketWorker.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Worker/ShareBasketWorker.php @@ -15,6 +15,7 @@ use Alchemy\Phrasea\Model\Manipulator\TokenManipulator; use Alchemy\Phrasea\Model\Repositories\BasketRepository; use Alchemy\Phrasea\Model\Repositories\UserRepository; +use Alchemy\Phrasea\Model\Repositories\WorkerRunningJobRepository; use Alchemy\Phrasea\Record\RecordReference; use Alchemy\Phrasea\WorkerManager\Queue\MessagePublisher; use DateTime; @@ -405,14 +406,7 @@ public function process(array $payload) $this->getLogger()->info("Basket with Id " . $basket->getId() . " successfully shared !"); if ($workerRunningJob != null) { - $workerRunningJob - ->setStatus(WorkerRunningJob::FINISHED) - ->setFinished(new \DateTime('now')) - ; - - $manager->persist($workerRunningJob); - - $manager->flush(); + $this->getRepoWorkerRunningJob()->markFinished($workerRunningJob->getId(), $this->getMessagePublisher(), MessagePublisher::SHARE_BASKET_TYPE); } // file_put_contents("./tmp/phraseanet-log.txt", sprintf("\n%s; ==== END (N = %d ; dT = %d ==> %0.2f / sec) ====\n\n", time(), $n_participants, time()-$_t0, $n_participants/(max(time()-$_t0, 0.001))), FILE_APPEND); @@ -500,4 +494,20 @@ private function getLogger() { return $this->app['alchemy_worker.logger']; } + + /** + * @return WorkerRunningJobRepository + */ + private function getRepoWorkerRunningJob() + { + return $this->app['repo.worker-running-job']; + } + + /** + * @return MessagePublisher + */ + private function getMessagePublisher() + { + return $this->app['alchemy_worker.message.publisher']; + } } diff --git a/lib/Alchemy/Phrasea/WorkerManager/Worker/SubdefCreationWorker.php b/lib/Alchemy/Phrasea/WorkerManager/Worker/SubdefCreationWorker.php index 9e647191f6..6869c36f99 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Worker/SubdefCreationWorker.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Worker/SubdefCreationWorker.php @@ -199,7 +199,7 @@ public function process(array $payload) $payload['subdefName'], $databox->get_viewname(), $databoxId, $recordId)); // tell that we have finished to work on this file (=unlock) - $this->repoWorker->markFinished($workerRunningJobId); + $this->repoWorker->markFinished($workerRunningJobId, $this->messagePublisher, MessagePublisher::SUBDEF_CREATION_TYPE); $this->getDataboxLogger($databox)->initOrUpdateLogDocsFromWorker($record, $databox, $workerRunningJob, $subdefName, \Session_Logger::EVENT_SUBDEFCREATION, new \DateTime('now'), WorkerRunningJob::FINISHED); } diff --git a/lib/Alchemy/Phrasea/WorkerManager/Worker/SubtitleWorker.php b/lib/Alchemy/Phrasea/WorkerManager/Worker/SubtitleWorker.php index 8119f509a1..74be8f339c 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Worker/SubtitleWorker.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Worker/SubtitleWorker.php @@ -38,13 +38,19 @@ class SubtitleWorker implements WorkerInterface private $workerRunningJob; private $transcriptionsId; - public function __construct(WorkerRunningJobRepository $repoWorker, PropertyAccess $conf, callable $appboxLocator, LoggerInterface $logger, EventDispatcherInterface $dispatcher) + /** + * @var MessagePublisher + */ + private $messagePublisher; + + public function __construct(WorkerRunningJobRepository $repoWorker, PropertyAccess $conf, callable $appboxLocator, LoggerInterface $logger, EventDispatcherInterface $dispatcher, $messagePublisher) { $this->repoWorker = $repoWorker; $this->conf = $conf; $this->appboxLocator = $appboxLocator; $this->logger = $logger; $this->dispatcher = $dispatcher; + $this->messagePublisher = $messagePublisher; } public function process(array $payload) @@ -265,7 +271,7 @@ public function process(array $payload) // $this->deleteTranscription($transcriptionId); // } - $this->jobFinished(); + $this->repoWorker->markFinished($this->workerRunningJob->getId(), $this->messagePublisher, MessagePublisher::SUBTITLE_TYPE); return 0; } diff --git a/lib/Alchemy/Phrasea/WorkerManager/Worker/WebhookWorker.php b/lib/Alchemy/Phrasea/WorkerManager/Worker/WebhookWorker.php index 593afbee5b..ed78038f7d 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Worker/WebhookWorker.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Worker/WebhookWorker.php @@ -137,14 +137,7 @@ public function process(array $payload) } if ($workerRunningJob != null) { - $workerRunningJob - ->setStatus(WorkerRunningJob::FINISHED) - ->setFinished(new \DateTime('now')) - ; - - $em->persist($workerRunningJob); - - $em->flush(); + $this->repoWorkerJob->markFinished($workerRunningJob->getId(), $this->messagePublisher, MessagePublisher::WEBHOOK_TYPE); } } } diff --git a/lib/Alchemy/Phrasea/WorkerManager/Worker/WriteMetadatasWorker.php b/lib/Alchemy/Phrasea/WorkerManager/Worker/WriteMetadatasWorker.php index a32ceadce7..a2ddca88b0 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Worker/WriteMetadatasWorker.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Worker/WriteMetadatasWorker.php @@ -96,7 +96,7 @@ public function process(array $payload) try { $record = $databox->get_record($recordId); } catch (\Exception $e) { - $this->repoWorker->markFinished($workerRunningJobId, "error " . $e->getMessage()); + $this->repoWorker->markFinished($workerRunningJobId, $this->messagePublisher, MessagePublisher::WRITE_METADATAS_TYPE, "error " . $e->getMessage()); return; } @@ -112,7 +112,7 @@ public function process(array $payload) $this->logger->error("Can't write meta on svg file!"); // tell that we have finished to work on this file ("unlock") - $this->repoWorker->markFinished($workerRunningJobId, "Can't write meta on svg file!"); + $this->repoWorker->markFinished($workerRunningJobId, $this->messagePublisher, MessagePublisher::WRITE_METADATAS_TYPE, "Can't write meta on svg file!"); $this->getDataboxLogger($databox)->initOrUpdateLogDocsFromWorker($record, $databox, $workerRunningJob, $subdefName, \Session_Logger::EVENT_WRITEMETADATAS, new \DateTime('now'), WorkerRunningJob::ERROR); @@ -323,7 +323,7 @@ public function process(array $payload) $this->updateJeton($record); // tell that we have finished to work on this file (=unlock) - $this->repoWorker->markFinished($workerRunningJobId, $stopInfo); + $this->repoWorker->markFinished($workerRunningJobId, $this->messagePublisher, MessagePublisher::WRITE_METADATAS_TYPE, $stopInfo); $this->getDataboxLogger($databox)->initOrUpdateLogDocsFromWorker($record, $databox, $workerRunningJob, $subdefName, \Session_Logger::EVENT_WRITEMETADATAS, new \DateTime('now'), WorkerRunningJob::ERROR); } return ; @@ -333,7 +333,7 @@ public function process(array $payload) $this->updateJeton($record); // tell that we have finished to work on this file (=unlock) - $this->repoWorker->markFinished($workerRunningJobId); + $this->repoWorker->markFinished($workerRunningJobId, $this->messagePublisher, MessagePublisher::WRITE_METADATAS_TYPE); $this->getDataboxLogger($databox)->initOrUpdateLogDocsFromWorker($record, $databox, $workerRunningJob, $subdefName, \Session_Logger::EVENT_WRITEMETADATAS, new \DateTime('now'), WorkerRunningJob::FINISHED); } From ef5dbc46c0f338b37511bd0f40a6407d26593004 Mon Sep 17 00:00:00 2001 From: Tac Tacelosky Date: Wed, 23 Oct 2024 14:23:03 -0400 Subject: [PATCH 09/12] fix typo (#4552) AWS spells it RESTful https://aws.amazon.com/what-is/restful-api/#:~:text=RESTful%20API%20is%20an%20interface,applications%20to%20perform%20various%20tasks. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4a304d06d7..e72cc4d369 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Phraseanet 4.1 - Digital Asset Management application - Several GUI : Prod, Admin, Thesaurus, Lightbox, Report, - Metadata Management (includes Thesaurus and DublinCore Mapping) - - RestFull APIS + - RESTful APIS - Elasticsearch search engine - Multiple resolution assets generation - Advanced Rights Management From f8046680c2d9acd5a29d322cb37d4e86ef927e6c Mon Sep 17 00:00:00 2001 From: Nicolas Maillat Date: Thu, 24 Oct 2024 17:43:06 +0200 Subject: [PATCH 10/12] Nginx bump 1.27.2 (#4557) --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index bca1bb3fcf..726ad0673a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -123,7 +123,7 @@ CMD ["/bin/bash", "bin/run-worker.sh"] # phraseanet-nginx ######################################################################### -FROM nginx:1.17.8-alpine AS phraseanet-nginx +FROM nginx:1.27.2-alpine AS phraseanet-nginx RUN adduser --uid 1000 --disabled-password app RUN apk add --update apache2-utils \ && rm -rf /var/cache/apk/* From 4dd8756f621bf37ff949244d57791d3d02c7b95c Mon Sep 17 00:00:00 2001 From: Nicolas Maillat Date: Thu, 24 Oct 2024 18:01:30 +0200 Subject: [PATCH 11/12] PHRAS-4101: Update Range for Subdefinition Image Sizes (#4558) --- lib/Alchemy/Phrasea/Media/Subdef/Image.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Image.php b/lib/Alchemy/Phrasea/Media/Subdef/Image.php index 4a881696b1..f3d00edd32 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Image.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Image.php @@ -33,7 +33,7 @@ public function __construct(TranslatorInterface $translator) { $this->translator = $translator; - $this->registerOption(new OptionType\Range($this->translator->trans('Dimension'), self::OPTION_SIZE, 20, 5000, 800)); + $this->registerOption(new OptionType\Range($this->translator->trans('Dimension'), self::OPTION_SIZE, 20, 10000, 800)); $this->registerOption(new OptionType\Range($this->translator->trans('Resolution'), self::OPTION_RESOLUTION, 50, 1000, 72)); $this->registerOption(new OptionType\Boolean($this->translator->trans('Remove ICC Profile'), self::OPTION_STRIP, false)); $this->registerOption(new OptionType\Boolean($this->translator->trans('Flatten layers'), self::OPTION_FLATTEN, true)); From 2b435b5a411cb262f49189da982c61f700e69999 Mon Sep 17 00:00:00 2001 From: Nicolas Maillat Date: Thu, 24 Oct 2024 19:10:04 +0200 Subject: [PATCH 12/12] PHRAS-4096 release of 4.1.10 (#4547) * Update CHANGELOG.md --- .env | 2 +- CHANGELOG.md | 60 ++++++++++++++++++++++++++++ lib/Alchemy/Phrasea/Core/Version.php | 2 +- 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/.env b/.env index 1983bf8287..8acdb77b78 100644 --- a/.env +++ b/.env @@ -143,7 +143,7 @@ PHRASEANET_DOCKER_REGISTRY=local # Docker images tag. # @run -PHRASEANET_DOCKER_TAG=4.1.9 +PHRASEANET_DOCKER_TAG=4.1.10 # Stack Name # An optionnal Name for the stack diff --git a/CHANGELOG.md b/CHANGELOG.md index acd2ae9f2e..e8e4a46d93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,65 @@ # CHANGELOG +## 4.1.10 + +### Update Instructions + +- **Migration Patch**: + - A migration script for the configuration file is available. Run the following command in the setup container with Docker if the environment variable `PHRASEANET_UPGRADE=1` is set: + ``` + bin/setup system:upgrade + ``` + +### Version Summary + +- **Bump Phraseanet Base Image to 1.1.0**: + - OS version updated. + - Bumped `Popeler` dependency . + - Added missing `ufraw` dependency . + +- **Updated Components**: + - **RabbitMQ**: Upgraded to version 3.8.34. + - **Nginx**: Updated to the latest stable release, 1.27.2. + +- **Security Fixes**: + - Fixed CSRF vulnerability in the userProfile endpoint. + - Addressed XSS injection vulnerability in the user profile. + - Corrected HTML injection in notification emails. + +- **Other Updates**: + - Updated translations. + +### Stack (Docker Compose and Helm) + +- **Phraseanet Base Image**: Version bumped. +- **RabbitMQ**: Version bumped. +- **Nginx**: Version bumped. +- **Helm Updates**: + - Added `nodeSelector` property to all charts except for the DB pod. + - `imagePullPolicy` can now be set from `values.yaml`. + - Release details: [Helm chart release 0.47.0](https://github.com/alchemy-fr/alchemy-helm-charts-repo/releases/tag/phraseanet-0.47.0) + +## What's Changed +* PHRAS-3416 : fix string in admin create subdef by @aynsix in https://github.com/alchemy-fr/Phraseanet/pull/4534 +* PHRAS-3416 create subdefinition localisation by @nmaillat in https://github.com/alchemy-fr/Phraseanet/pull/4537 +* PHRAS-4094 Bump rabbitMQ version to 3.8.34 by @gjacobjn in https://github.com/alchemy-fr/Phraseanet/pull/4546 +* PHRAS-4090:Prod - expose-cli - publication - publication description is Nok by @aynsix in https://github.com/alchemy-fr/Phraseanet/pull/4536 +* Fix for phraseanet-saml-sp image build in Dockerfile by @gjacobjn in https://github.com/alchemy-fr/Phraseanet/pull/4543 +* PHRAS-4100 Php upload tmp directory by @nmaillat in https://github.com/alchemy-fr/Phraseanet/pull/4553 +* PHRAS-4079 Bump base image 1.1.0 by @moctardiouf in https://github.com/alchemy-fr/Phraseanet/pull/4554 +* PHRAS-3857 : Check CSRF token on account by @aynsix in https://github.com/alchemy-fr/Phraseanet/pull/4556 +* PHRAS-4103 Prod xss check by @aynsix in https://github.com/alchemy-fr/Phraseanet/pull/4555 +* PHRAS-4088: improving Job ack in workerRunningJob by @aynsix in https://github.com/alchemy-fr/Phraseanet/pull/4535 +* fix typo by @tacman in https://github.com/alchemy-fr/Phraseanet/pull/4552 +* PHRAS-4104 Nginx bump 1.27.2 by @nmaillat in https://github.com/alchemy-fr/Phraseanet/pull/4557 +* PHRAS-4101: Update Range for Subdefinition Image Sizes by @nmaillat in https://github.com/alchemy-fr/Phraseanet/pull/4558 + +## New Contributors +* @tacman made their first contribution in https://github.com/alchemy-fr/Phraseanet/pull/4552 + +**Full Changelog**: https://github.com/alchemy-fr/Phraseanet/compare/4.1.9...4.1.10 + +___ ## 4.1.9 ### Update instructions diff --git a/lib/Alchemy/Phrasea/Core/Version.php b/lib/Alchemy/Phrasea/Core/Version.php index ad0a782b48..840762685a 100644 --- a/lib/Alchemy/Phrasea/Core/Version.php +++ b/lib/Alchemy/Phrasea/Core/Version.php @@ -17,7 +17,7 @@ class Version * @var string */ - private $number = '4.1.9'; + private $number = '4.1.10'; /** * @var string