diff --git a/lib/pear/HTML/Common.php b/lib/pear/HTML/Common.php
index b86217910a5..3797cc3b736 100644
--- a/lib/pear/HTML/Common.php
+++ b/lib/pear/HTML/Common.php
@@ -168,7 +168,7 @@ class HTML_Common {
if (is_array($attributes)) {
foreach ($attributes as $key => $value) {
- $strAttr .= ' ' . $key . '="' . htmlspecialchars($value) . '"';
+ $strAttr .= ' ' . $key . '="' . htmlspecialchars($value ?? '') . '"';
}
}
return $strAttr;
diff --git a/lib/pear/HTML/QuickForm.php b/lib/pear/HTML/QuickForm.php
index c1a8473efac..fe0fcac580b 100644
--- a/lib/pear/HTML/QuickForm.php
+++ b/lib/pear/HTML/QuickForm.php
@@ -733,7 +733,7 @@ class HTML_QuickForm extends HTML_Common {
{
static $anonGroups = 1;
- if (0 == strlen($name)) {
+ if (0 == strlen($name ?? '')) {
$name = 'qf_group_' . $anonGroups++;
$appendName = false;
}
@@ -813,6 +813,7 @@ class HTML_QuickForm extends HTML_Common {
function getSubmitValue($elementName)
{
$value = null;
+ $elementName = $elementName ?? '';
if (isset($this->_submitValues[$elementName]) || isset($this->_submitFiles[$elementName])) {
$value = isset($this->_submitValues[$elementName])? $this->_submitValues[$elementName]: array();
if (is_array($value) && isset($this->_submitFiles[$elementName])) {
diff --git a/lib/pear/HTML/QuickForm/RuleRegistry.php b/lib/pear/HTML/QuickForm/RuleRegistry.php
index 08ba246891a..baa506d8b1f 100644
--- a/lib/pear/HTML/QuickForm/RuleRegistry.php
+++ b/lib/pear/HTML/QuickForm/RuleRegistry.php
@@ -76,7 +76,7 @@ class HTML_QuickForm_RuleRegistry
*/
function registerRule($ruleName, $type, $data1, $data2 = null)
{
- $type = strtolower($type);
+ $type = strtolower($type ?? '');
if ($type == 'regex') {
// Regular expression
$rule =& $this->getRule('regex');
diff --git a/lib/pear/HTML/QuickForm/element.php b/lib/pear/HTML/QuickForm/element.php
index 042f1910d63..37e2e1bbff7 100644
--- a/lib/pear/HTML/QuickForm/element.php
+++ b/lib/pear/HTML/QuickForm/element.php
@@ -351,7 +351,7 @@ class HTML_QuickForm_element extends HTML_Common
if (empty($values)) {
return null;
}
- $elementName = $this->getName();
+ $elementName = $this->getName() ?? '';
if (isset($values[$elementName])) {
return $values[$elementName];
} elseif (strpos($elementName, '[')) {
@@ -447,7 +447,7 @@ class HTML_QuickForm_element extends HTML_Common
return;
}
- $id = $this->getName();
+ $id = $this->getName() ?? '';
$id = 'id_' . str_replace(array('qf_', '[', ']'), array('', '_', ''), $id);
$id = clean_param($id, PARAM_ALPHANUMEXT);
$this->updateAttributes(array('id' => $id));
diff --git a/lib/pear/readme_moodle.txt b/lib/pear/readme_moodle.txt
index 3a8a9efe6a5..bf506807bf5 100644
--- a/lib/pear/readme_moodle.txt
+++ b/lib/pear/readme_moodle.txt
@@ -32,6 +32,7 @@ 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
Pear
====