From 93958f19af3bfcf689758673fdaaaed69b2a1ab1 Mon Sep 17 00:00:00 2001 From: Dave MacFarlane Date: Mon, 18 Oct 2021 10:37:04 -0400 Subject: [PATCH] [Instrument] Fix type error in some instruments When accessing an instrument from RB, I got the error: ``` Fatal error: Uncaught TypeError: Argument 1 passed to ValidatableIdentifier::__construct() must be of the type string, null given, called in /home/driusan/Code/Loris/php/libraries/NDB_BVL_Instrument.class.inc on line 2863 and defined in /home/driusan/Code/Loris/php/libraries/Valida tableIdentifier.php:57 Stack trace: #0 /home/driusan/Code/Loris/php/libraries/NDB_BVL_Instrument.class.inc(2863): ValidatableIdentifier->__co nstruct(NULL) #1 /home/driusan/Code/Loris/src/Middleware/UserPageDecorationMiddleware.php(241): NDB_BVL_Instrument->handle(Object(Laminas\Dia ctoros\ServerRequest)) #2 /home/driusan/Code/Loris/src/Middleware/PageDecorationMiddleware.php(57): LORIS\Middleware\UserPageDecorationMiddle ware->process(Object(Laminas\Diactoros\ServerRequest), Object(NDB_BVL_Instrument_aosi)) #3 /home/driusan/Code/Loris/php/libraries/NDB_Page.cl ass.inc(735): LORIS\Middleware\PageDecorationMiddleware->process(Object(Laminas\Diactoros\ServerRequest), Object(NDB_BVL_Instrument_aosi)) #4 /home/driusan/Code/Loris/php/libraries/NDB_BVL_In in /home/driusan/Code/Loris/php/libraries/ValidatableIdentifier.php on line 57 ``` This fixes the type error so that the instrument page loads. --- php/libraries/NDB_BVL_Instrument.class.inc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/php/libraries/NDB_BVL_Instrument.class.inc b/php/libraries/NDB_BVL_Instrument.class.inc index 8e88e437758..a1571d58ec7 100644 --- a/php/libraries/NDB_BVL_Instrument.class.inc +++ b/php/libraries/NDB_BVL_Instrument.class.inc @@ -2860,7 +2860,9 @@ abstract class NDB_BVL_Instrument extends NDB_Page // Disable form if data entry is complete $user = $request->getAttribute("user"); $sessionID = $request->getQueryParams()["sessionID"]; - $timepoint = \Timepoint::singleton(new SessionID($sessionID)); + if ($sessionID !== null) { + $timepoint = \Timepoint::singleton(new SessionID($sessionID)); + } // create an instrument status object $status = new \NDB_BVL_InstrumentStatus($this->loris);