Error
Exception - count(): Argument #1 ($value) must be of type Countable|array, null given
Debug info:
Error code: generalexceptionmessage
Stack trace:
line 228 of /theme/moove/classes/util/settings.php: TypeError thrown
line 228 of /theme/moove/classes/util/settings.php: call to count()
line 128 of /theme/moove/classes/util/settings.php: call to theme_moove\util\settings->faq()
line 125 of /theme/moove/layout/frontpage.php: call to theme_moove\util\settings->frontpage()
line 1473 of /lib/outputrenderers.php: call to include()
line 1399 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
line 116 of /index.php: call to core_renderer->header()
The error is triggered if the number of FAQ questions on the frontpage is set to let's say 3 but no questions/answers are provided. Yes, stupid mistake of a local Moodle manager. Unfortunately, it renders the site inaccessible for normal users since the error is displayed instead of the frontpage.
The offending code is:
if (count($templatecontext['faq'])) {
$templatecontext['faqenabled'] = true;
}
A solution could be to use
if (!empty($templatecontext['faq'])) {
$templatecontext['faqenabled'] = true;
}
Error Exception - count(): Argument #1 ($value) must be of type Countable|array, null given
Debug info: Error code: generalexceptionmessage
Stack trace: line 228 of /theme/moove/classes/util/settings.php: TypeError thrown line 228 of /theme/moove/classes/util/settings.php: call to count() line 128 of /theme/moove/classes/util/settings.php: call to theme_moove\util\settings->faq() line 125 of /theme/moove/layout/frontpage.php: call to theme_moove\util\settings->frontpage() line 1473 of /lib/outputrenderers.php: call to include() line 1399 of /lib/outputrenderers.php: call to core_renderer->render_page_layout() line 116 of /index.php: call to core_renderer->header()
The error is triggered if the number of FAQ questions on the frontpage is set to let's say 3 but no questions/answers are provided. Yes, stupid mistake of a local Moodle manager. Unfortunately, it renders the site inaccessible for normal users since the error is displayed instead of the frontpage.
The offending code is: if (count($templatecontext['faq'])) { $templatecontext['faqenabled'] = true; }
A solution could be to use if (!empty($templatecontext['faq'])) { $templatecontext['faqenabled'] = true; }