From 8a0b2c8d408bc1d4ebb07c226e024ec3d6bdb0c3 Mon Sep 17 00:00:00 2001 From: regis Date: Thu, 12 Jan 2023 11:31:09 -0500 Subject: [PATCH] [core] Fix incorrect message/error for instrument access (#8284) An incorrect error message was displayed on the frontend when a user did not have the permission to access an instrument. The code was test looping on ALL permissions, but it failed when trying to do so on only ONE permission (the loop went through the instrument name and permission instead of the actual instruments objects). Resolves #8171 --- php/libraries/NDB_BVL_Instrument.class.inc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/php/libraries/NDB_BVL_Instrument.class.inc b/php/libraries/NDB_BVL_Instrument.class.inc index 25aed6f03ff..e9f546c7bda 100644 --- a/php/libraries/NDB_BVL_Instrument.class.inc +++ b/php/libraries/NDB_BVL_Instrument.class.inc @@ -362,10 +362,18 @@ abstract class NDB_BVL_Instrument extends NDB_Page } else { //check if user has instrument's permissions //is the instrument listed at all in instrumentPermissions? $instrumentListed = false; - foreach ($instrumentPermissions["instrument"] as $instrument) { + // get an array of instruments + // if one instrument, get it into an array + $instrumentList = Utility::asArray( + $instrumentPermissions["instrument"] + ); + // iterate through instruments + foreach ($instrumentList as $instrument) { if ($instrument["Test_name"] == $this->testName) { $instrumentListed = true; - $instrumentPerms = Utility::asArray($instrument["permission"]); + $instrumentPerms = Utility::asArray( + $instrument["permission"] + ); } }