From bfb103ef581d62aa4387df3efd9882be1fe16c25 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 13 Apr 2022 13:47:07 +1200 Subject: [PATCH] ENH PHP 8.1 compatibility --- src/SitewideContentReport.php | 2 +- tests/php/SitewideContentReportTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SitewideContentReport.php b/src/SitewideContentReport.php index cc44f8c..eea1fc4 100644 --- a/src/SitewideContentReport.php +++ b/src/SitewideContentReport.php @@ -73,7 +73,7 @@ public function sourceRecords($params = []) 'Files' => Subsite::get_from_all_subsites(File::class), ]; - if (array_key_exists('AllSubsites', $params)) { + if (array_key_exists('AllSubsites', $params ?? [])) { $items['Pages'] = $items['Pages']->filter(['SubsiteID' => $params['AllSubsites']]); $items['Files'] = $items['Files']->filter(['SubsiteID' => [0, $params['AllSubsites']]]); } diff --git a/tests/php/SitewideContentReportTest.php b/tests/php/SitewideContentReportTest.php index 5547feb..bd1650b 100644 --- a/tests/php/SitewideContentReportTest.php +++ b/tests/php/SitewideContentReportTest.php @@ -75,7 +75,7 @@ public function testParameterFields() if (class_exists(Subsite::class)) { /** @var DropdownField $field */ $field = $fields->fieldByName('AllSubsites'); - $keys = array_filter(array_keys($field->getSource())); + $keys = array_filter(array_keys($field->getSource() ?? [])); $this->assertCount(4, $keys, '2 subsites plus 2 added options to filter by subsite'); } else {