From 286683b2c953fe6f2a17302dd2e33d98e6b0bd86 Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Tue, 5 May 2020 09:56:58 +0100 Subject: [PATCH] FIX #13126 TIME 0:10 folder print error without link mail + test publish code coverage --- .gitlab-ci.yml | 14 ++++++++++++++ .../controllers/FolderPrintController.php | 19 +++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7e6e3279918..ea072a0a3dc 100755 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,6 +10,7 @@ variables: stages: - test + - deploy before_script: - apt-get update -yqq > /dev/null @@ -107,3 +108,16 @@ job_php-7.2: - develop except: - schedules + +pages: + stage: deploy + dependencies: + - job_php-7.4 + script: + - mv test/unitTests/build/ public/ + artifacts: + paths: + - public + expire_in: 1 day + only: + - develop diff --git a/src/app/resource/controllers/FolderPrintController.php b/src/app/resource/controllers/FolderPrintController.php index 6a357e8aa05..f3001bd61a0 100755 --- a/src/app/resource/controllers/FolderPrintController.php +++ b/src/app/resource/controllers/FolderPrintController.php @@ -392,13 +392,16 @@ class FolderPrintController } else { $oLinkedResources = ResModel::getById(['resId' => $resource['resId'], 'select' => ['linked_resources']]); $linkedResources = json_decode($oLinkedResources['linked_resources'], true); - $attachments = AttachmentModel::get([ - 'select' => ['res_id', 'res_id_master', 'recipient_type', 'recipient_id', 'typist', 'status', 'attachment_type', - 'creation_date', 'identifier', 'title', 'format', 'docserver_id', 'origin'], - 'where' => ['res_id_master in (?)', 'status not in (?)'], - 'data' => [$linkedResources, ['DEL', 'OBS']], - 'orderBy' => ['creation_date desc'] - ]); + $attachments = []; + if (!empty($linkedResources)) { + $attachments = AttachmentModel::get([ + 'select' => ['res_id', 'res_id_master', 'recipient_type', 'recipient_id', 'typist', 'status', 'attachment_type', + 'creation_date', 'identifier', 'title', 'format', 'docserver_id', 'origin'], + 'where' => ['res_id_master in (?)', 'status not in (?)'], + 'data' => [$linkedResources, ['DEL', 'OBS']], + 'orderBy' => ['creation_date desc'] + ]); + } } $attachmentsIds = array_column($attachments, 'res_id'); @@ -447,7 +450,7 @@ class FolderPrintController if (!is_array($resource['linkedResources'])) { $resource['linkedResources'] = $controlResource['linked_resources']; } - if (!ResController::hasRightByResId(['resId' => $resource['linkedResources'], 'userId' => $GLOBALS['id']])) { + if (!empty($resource['linkedResources']) && !ResController::hasRightByResId(['resId' => $resource['linkedResources'], 'userId' => $GLOBALS['id']])) { return $response->withStatus(403)->withJson(['errors' => 'LinkedResources out of perimeter']); } foreach ($resource['linkedResources'] as $linkedResource) { -- GitLab