From 319e7a4b01d6e8f395c0ea155786afd960f32f73 Mon Sep 17 00:00:00 2001 From: "Scott J. Pearson" Date: Fri, 11 Dec 2020 15:29:26 -0600 Subject: [PATCH] 2.25.11 --- CareerDev.php | 2 +- classes/REDCapManagement.php | 1 + classes/Scholar.php | 4 +++- classes/Upload.php | 14 ++++++++------ 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CareerDev.php b/CareerDev.php index 8a9693f1..e025632b 100644 --- a/CareerDev.php +++ b/CareerDev.php @@ -9,7 +9,7 @@ class CareerDev { public static $passedModule = NULL; public static function getVersion() { - return "2.25.10"; + return "2.25.11"; } public static function getLockFile($pid) { diff --git a/classes/REDCapManagement.php b/classes/REDCapManagement.php index 9cda9f47..c227ff77 100644 --- a/classes/REDCapManagement.php +++ b/classes/REDCapManagement.php @@ -1178,6 +1178,7 @@ public static function datetime2Date($datetime) { } public static function prefix2CompleteField($prefix) { + $prefix = preg_replace("/_$/", "", $prefix); if ($prefix == "promotion") { return "position_change_complete"; } else if ($prefix == "check") { diff --git a/classes/Scholar.php b/classes/Scholar.php index 644123c0..b7b57471 100644 --- a/classes/Scholar.php +++ b/classes/Scholar.php @@ -983,7 +983,9 @@ private function getAllOtherInstitutions($rows) { } } } - Application::log("In getAllOtherInstitutions, returning ".json_encode($seenInstitutions)); + if ($showDebug) { + Application::log("In getAllOtherInstitutions, returning ".json_encode($seenInstitutions)); + } return $seenInstitutions; } diff --git a/classes/Upload.php b/classes/Upload.php index 947cc761..8d1bb66b 100644 --- a/classes/Upload.php +++ b/classes/Upload.php @@ -132,7 +132,7 @@ public static function deleteRecords($token, $server, $records) { Application::log("Deleted ".$output); $feedback = json_decode($output, TRUE); - self::testFeedback($feedback); + self::testFeedback($feedback, $output); return $feedback; } @@ -169,15 +169,17 @@ public static function metadata($metadata, $token, $server) { curl_close($ch); $feedback = json_decode($output, TRUE); - self::testFeedback($feedback, $metadata); + self::testFeedback($feedback, $output, $metadata); self::$useAPIOnly[$token] = TRUE; Application::log("Upload::metadata returning $output"); return $feedback; } - private static function testFeedback($feedback, $rows = array()) { - if (isset($feedback['error']) && $feedback['error']) { + private static function testFeedback($feedback, $originalText, $rows = array()) { + if (!$feedback) { + throw new \Exception("Upload error (non-JSON): $originalText"); + } else if (isset($feedback['error']) && $feedback['error']) { Application::log("Upload error: ".$feedback['error']); throw new \Exception("Error: ".$feedback['error']."\n".json_encode($rows)); } @@ -266,7 +268,7 @@ public static function projectSettings($settings, $token, $server) { curl_close($ch); $feedback = json_decode($output, TRUE); - self::testFeedback($feedback, $settings); + self::testFeedback($feedback, $output, $settings); self::$useAPIOnly[$token] = TRUE; Application::log("Upload::projectSettings returning $output"); @@ -428,7 +430,7 @@ public static function rows($rows, $token, $server) { } else { Application::log("Upload::rows $method returning $output in ".($time3 - $time2)." seconds"); } - self::testFeedback($feedback, $rows); + self::testFeedback($feedback, $output, $rows); $allFeedback = self::combineFeedback($allFeedback, $feedback); } return $allFeedback;