MDL-74824 core: Do not treat Stringable objects as arrays

Co-authored-by: Paul Holden <[email protected]>
This commit is contained in:
Andrew Nicols
2023-06-11 17:40:55 +01:00
committed by Paul Holden
co-authored by Paul Holden
parent d508cdf111
commit fe827375f3
3 changed files with 5 additions and 3 deletions
+2 -2
View File
@@ -363,7 +363,7 @@ class core_string_manager_standard implements core_string_manager {
if ($a !== null) {
// Process array's and objects (except lang_strings).
if (is_array($a) or (is_object($a) && !($a instanceof lang_string))) {
if (is_array($a) or (is_object($a) && !($a instanceof Stringable))) {
$a = (array)$a;
$search = array();
$replace = array();
@@ -372,7 +372,7 @@ class core_string_manager_standard implements core_string_manager {
// We do not support numeric keys - sorry!
continue;
}
if (is_array($value) or (is_object($value) && !($value instanceof lang_string))) {
if (is_array($value) or (is_object($value) && !($value instanceof Stringable))) {
// We support just string or lang_string as value.
continue;
}
@@ -61,7 +61,7 @@ class send_login_notifications extends adhoc_task {
$userauth = get_auth_plugin($USER->auth);
if ($userauth->can_change_password()) {
if ($changepwurl = $userauth->change_password_url()) {
$changepasswordlink = (string) $changepwurl;
$changepasswordlink = $changepwurl;
} else {
$changepasswordlink = (new \moodle_url('/login/change_password.php'))->out(false);
}
+2
View File
@@ -5,6 +5,8 @@ information provided here is intended especially for developers.
* Admin settings for passwords (admin_setting_configpasswordunmask) can now be a required field using the following class:
- admin_setting_requiredpasswordunmask
* The `$a` argument passed to `get_string` can now include any stringable type, removing the need for explicit casts (for
example, of `\moodle_url` instances)
* The badges_get_oauth2_service_options() method has been deprecated, because it's not required anymore. It should no longer
be used.
* Support for the following phpunit coverage info properties, deprecated since 3.11, has been removed: