Skip to content

Conversation

daniil-berg
Copy link

As of PHP 8.2, assigning properties dynamically causes a deprecation warning. To reproduce this specific problem, just set the following in your config.php:

$CFG->debug = E_ALL;
$CFG->debugdisplay = 1;

And go to (for example) http://your.moodle/admin/settings.php?section=authsettinganonymous to see the notice:

Creation of dynamic property auth_plugin_anonymous::$FIRSTNAME is deprecated

This Patch simply adds the missing declarations.

Also, since PHP will coerce values to the declared types of the class properties, the intval call becomes unnecessary.


Finally, unrelated to the previous issue, but too small for a separate PR:

There was a typo in the same constructor. Instead of role the desired config property is called assignrole. See line 97 here:

$settings->add(new admin_setting_configselect(
'auth_anonymous/assignrole',
get_string('role', 'auth_anonymous'),
get_string('role_desc', 'auth_anonymous'),
0,
$roles,
PARAM_INT
));


With these changes, using the aforementioned debug configuration will no longer produce warnings/error messages.

- remove now unneeded `int` cast for `timeout` config property
- fix typo replacing `role` config property access with `assignrole`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant