catalyst / moodle-auth_saml2

SAML done 100% in Moodle, fast, simple, secure
https://moodle.org/plugins/auth_saml2
70 stars 132 forks source link

Fix PHP 8.1 warning related to null whitelist #757

Closed sammarshallou closed 1 year ago

sammarshallou commented 1 year ago

If an entry in auth_saml2_idps is created by the admin settings screen (via the class setting_idpmetadata.php, line 181) then the field 'whitelist' will be null. (If you later edit it using the auth/saml2/availableidps.php script then it will probably be set to blank.)

When the field is null, it causes a warning in PHP 8.1 because the function check_whitelisted_ip_redirect calls core function is_ip_in_subnet_list with parameter 2 null. It then passes the null to core function 'explode' parameter 2, which now causes this warning:

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /var/www/html/moodle/lib/classess/ip_utils.php on line 237

Since the code worked before, it should be fine to pass empty string instead.

danmarsden commented 1 year ago

cool - thanks Sam!!