From 0ce4005c179433ea7afde95932ac24960742cbb7 Mon Sep 17 00:00:00 2001 From: Brian Foley Date: Tue, 15 Sep 2026 22:04:03 +0100 Subject: [PATCH] project_quick_check.inc: Handle load_project_words failures If load_project_words fails, eg if it can't read the words file, it returns a string with an error message. Report this failure. Found by `phpstan analyse --level 7` --- pinc/project_quick_check.inc | 39 +++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/pinc/project_quick_check.inc b/pinc/project_quick_check.inc index 75c970f65..5c7a319bf 100644 --- a/pinc/project_quick_check.inc +++ b/pinc/project_quick_check.inc @@ -643,23 +643,38 @@ function tds_for_invalid_chars(string $raw): string function _test_project_for_word_lists(string $projectid): PQCResult { - $num_good_words = count(load_project_good_words($projectid)); - $num_bad_words = count(load_project_bad_words($projectid)); + $good_words = load_project_good_words($projectid); + $bad_words = load_project_bad_words($projectid); $test_name = _("Good/Bad Wordlists"); $test_desc = _("This test checks if the project good and bad word lists are populated."); - $details = "

"; - - if ($num_good_words || $num_bad_words) { - $status = _("Success"); - $summary = _("At least one of the good and bad word lists have entries."); + if (is_string($good_words) || is_string($bad_words)) { + $details = "

"; + $summary = _("Error loading word lists."); + $status = _("Error"); } else { - $status = _("Warning"); - $summary = _("Both of the word lists are empty."); + $num_good_words = count($good_words); + $num_bad_words = count($bad_words); + $details = "

"; + + if ($num_good_words || $num_bad_words) { + $status = _("Success"); + $summary = _("At least one of the good and bad word lists have entries."); + } else { + $status = _("Warning"); + $summary = _("Both of the word lists are empty."); + } } return new PQCResult($test_name, $test_desc, $status, $summary, $details);