Merge branch 'MDL-70920-master' of git://github.com/marinaglancy/moodle

This commit is contained in:
Eloy Lafuente (stronk7)
2021-02-23 17:43:32 +01:00
5 changed files with 16 additions and 5 deletions
+3 -2
View File
@@ -207,7 +207,8 @@ abstract class base_moodleform extends moodleform {
$this->add_html_formatting($setting);
// Then call the add method with the get_element_properties array.
call_user_func_array(array($this->_form, 'addElement'), $setting->get_ui()->get_element_properties($task, $OUTPUT));
call_user_func_array(array($this->_form, 'addElement'),
array_values($setting->get_ui()->get_element_properties($task, $OUTPUT)));
$this->_form->setType($setting->get_ui_name(), $setting->get_param_validation());
$defaults[$setting->get_ui_name()] = $setting->get_value();
if ($setting->has_help()) {
@@ -335,7 +336,7 @@ abstract class base_moodleform extends moodleform {
$mform = $this->_form;
// Apply all dependencies for backup.
foreach ($setting->get_my_dependency_properties() as $key => $dependency) {
call_user_func_array(array($this->_form, 'disabledIf'), $dependency);
call_user_func_array(array($this->_form, 'disabledIf'), array_values($dependency));
}
}
+1 -1
View File
@@ -144,7 +144,7 @@ class core_shutdown_manager {
error_log('Invalid custom shutdown function detected '.var_export($callback, true));
// @codingStandardsIgnoreEnd
}
self::$callbacks[] = [$callback, $params ?? []];
self::$callbacks[] = [$callback, $params ? array_values($params) : []];
}
/**
+1 -1
View File
@@ -1237,7 +1237,7 @@ abstract class sql_generator {
}
// Now call the standard $DB->sql_concat() DML function
return call_user_func_array(array($this->mdb, 'sql_concat'), $elements);
return call_user_func_array(array($this->mdb, 'sql_concat'), array_values($elements));
}
/**
+1 -1
View File
@@ -1426,7 +1426,7 @@ class sqlsrv_native_moodle_database extends moodle_database {
for ($n = count($elements) - 1; $n > 0; $n--) {
array_splice($elements, $n, 0, $separator);
}
return call_user_func_array(array($this, 'sql_concat'), $elements);
return call_user_func_array(array($this, 'sql_concat'), array_values($elements));
}
public function sql_isempty($tablename, $fieldname, $nullablefield, $textfield) {
+10
View File
@@ -8062,6 +8062,16 @@ function component_callback($component, $function, array $params = array(), $def
$functionname = component_callback_exists($component, $function);
if ($params && (array_keys($params) !== range(0, count($params) - 1))) {
// PHP 8 allows to have associative arrays in the call_user_func_array() parameters but
// PHP 7 does not. Using associative arrays can result in different behavior in different PHP versions.
// See https://php.watch/versions/8.0/named-parameters#named-params-call_user_func_array
// This check can be removed when minimum PHP version for Moodle is raised to 8.
debugging('Parameters array can not be an associative array while Moodle supports both PHP 7 and PHP 8.',
DEBUG_DEVELOPER);
$params = array_values($params);
}
if ($functionname) {
// Function exists, so just return function result.
$ret = call_user_func_array($functionname, $params);