You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This should be replaced with throwing an exception.
The text was updated successfully, but these errors were encountered:
danowar2k
changed the title
Call of since Moodle 4.1 deprecated function print_error()
Call of deprecated function print_error() (since Moodle 4.1)
Jan 8, 2025
The error you're encountering happens because the print_error() function was deprecated in Moodle 4.1. The recommended approach now is to replace the use of print_error() with throwing an exception, which is more aligned with modern PHP practices and Moodle's exception handling system.
Here's how you can address this issue:
Locate the print_error function call:
In the file moodle-auth_saml2/autologin.php, line 34, you have the following call:
Replace print_error() with an exception:
Instead of using print_error(), you should throw a moodle_exception. This is Moodle's preferred method for error handling now.
The moodle_exception class is designed to handle errors more efficiently, and it integrates with Moodle's error handling framework, including displaying the error message appropriately.
Why is this change necessary?
Deprecation: print_error() was deprecated as of Moodle 4.1 in favour of exception handling, which allows for better error reporting and debugging.
Exception Handling: Throwing an exception is a more modern and consistent way to handle errors in object-oriented programming. Exceptions can be caught, logged, and managed in a way that improves maintainability and readability of the code.
Final Updated Code:
// Line 34 in autologin.phpthrownewmoodle_exception('errorinvalidautologin', 'auth_saml2');
This will ensure that the code aligns with Moodle's new error handling practices and should resolve the deprecation warning you're seeing.
danmarsden
changed the title
Call of deprecated function print_error() (since Moodle 4.1)
Call of deprecated function print_error() in autologin.php
Jan 20, 2025
What happened?
Moodle's print_error() function is deprecated since Moodle 4.1, see https://tracker.moodle.org/browse/MDL-71062
The code still contains a spot where print_error() is used:
moodle-auth_saml2/autologin.php
Line 34 in 54928e5
This should be replaced with throwing an exception.
The text was updated successfully, but these errors were encountered: