From 6acc34a0977103827b78e0d8c20ec72192c90623 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Tue, 31 Jan 2023 10:06:52 +0000 Subject: [PATCH] MDL-77081 forms: PHP8.1 compatibility for group/textarea elements. See related changes in b0a83aa7, we can no longer pass null values to some string related methods. --- lib/formslib.php | 2 +- lib/pear/HTML/QuickForm/textarea.php | 2 +- lib/pear/readme_moodle.txt | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/formslib.php b/lib/formslib.php index 4bb23d26df1..df47c7b09e0 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -3195,7 +3195,7 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{ $html = str_replace('{groupname}', 'data-groupname="'.$group->getName().'"', $html); $html = str_replace('{typeclass}', 'fgroup', $html); $html = str_replace('{type}', 'group', $html); - $html = str_replace('{class}', $group->getAttribute('class'), $html); + $html = str_replace('{class}', $group->getAttribute('class') ?? '', $html); $emptylabel = ''; if ($group->getLabel() == '') { $emptylabel = 'femptylabel'; diff --git a/lib/pear/HTML/QuickForm/textarea.php b/lib/pear/HTML/QuickForm/textarea.php index 9967f59b527..52cd0080291 100644 --- a/lib/pear/HTML/QuickForm/textarea.php +++ b/lib/pear/HTML/QuickForm/textarea.php @@ -199,7 +199,7 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element return $this->_getTabs() . '_getAttrString($this->_attributes) . '>' . // because we wrap the form later we don't want the text indented - preg_replace("/(\r\n|\n|\r)/", ' ', htmlspecialchars($this->_value)) . + preg_replace("/(\r\n|\n|\r)/", ' ', htmlspecialchars($this->_value ?? '')) . ''; } } //end func toHtml diff --git a/lib/pear/readme_moodle.txt b/lib/pear/readme_moodle.txt index bf506807bf5..b3a0e70d4b7 100644 --- a/lib/pear/readme_moodle.txt +++ b/lib/pear/readme_moodle.txt @@ -32,7 +32,8 @@ MDL-70457 - PHP 7.4 curly brackets string access fix. MDL-71126 - Quiz: Manual grading page size preference can get stuck at 0 Including in this change: - New positiveint regex rule to check if the value is a positive integer -MDL-76102 - PHP 8.1 passing null to a non-nullable argument of a built-in function is deprecated +MDL-76102 / MDL-77081 + PHP 8.1 passing null to a non-nullable argument of a built-in function is deprecated Pear ====