From: Tim Otten Date: Thu, 9 Apr 2020 04:20:40 +0000 (-0700) Subject: Mitigate flaky test failure about "CRM_Utils_Check_Component_Env->checkVersion()" X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=0770d5cb04cb828e0893b114661db9dae49afa4d;p=civicrm-core.git Mitigate flaky test failure about "CRM_Utils_Check_Component_Env->checkVersion()" This function relies on an external data feed. If it fails to fetch the feed, then we wind up with a PHP warning: ``` Invalid argument supplied for foreach() in CRM_Utils_Check_Component_Env->checkVersion() (line 475 of /home/me/bknix/build/dmaster/web/sites/all/modules/civicrm/CRM/Utils/Check/Component/Env.php). ``` In certain unit-tests, this warning becomes a false-negative test-failure. I saw these tests failing recently: ``` CRM_Contact_Page_View_UserDashBoardTest.testDashboardContentContributionsWithInvoicingEnabled CRM_Contact_Page_View_UserDashBoardTest.testDashboardContentContributions CRM_Core_Page_HookTest.testFormsCallBuildFormOnce CRM_Core_Page_HookTest.testPagesCallPageRunOnce ``` Note that it is legit to have some QA signals if the web-service fials, but that's more of a monitoring issue for the web-service. It shouldn't manifest in random unit-tests or random page-views. --- diff --git a/CRM/Utils/Check/Component/Env.php b/CRM/Utils/Check/Component/Env.php index 185ed5f9c2..63efaddef8 100644 --- a/CRM/Utils/Check/Component/Env.php +++ b/CRM/Utils/Check/Component/Env.php @@ -471,7 +471,7 @@ class CRM_Utils_Check_Component_Env extends CRM_Utils_Check_Component { 'warning' => CRM_Utils_Check::severityMap(\Psr\Log\LogLevel::WARNING) , 'critical' => CRM_Utils_Check::severityMap(\Psr\Log\LogLevel::CRITICAL), ]; - foreach ($vc->getVersionMessages() as $msg) { + foreach ($vc->getVersionMessages() ?? [] as $msg) { $messages[] = new CRM_Utils_Check_Message(__FUNCTION__ . '_' . $msg['name'], $msg['message'], $msg['title'], $severities[$msg['severity']], 'fa-cloud-upload'); }