Fatal Errors under PHP 8.1
-
While preparing our websites for the upgrade to PHP 8.x, I discovered a handful of errors in the 3.6.1 version of the Authorizer plugin–something we depend on heavily.
The first of these was:PHP Fatal error: Uncaught TypeError: Unsupported operand types: string * int in /dom25405/wp-content/plugins/authorizer/src/authorizer/class-authentication.php:86
I was able to repair this and the related code with a series of casts:
$reset_duration = (int)$lockouts['reset_duration'] * 60; // minutes to seconds. $num_attempts_long_lockout = (int)$lockouts['attempts_1'] + (int)$lockouts['attempts_2']; $num_attempts_short_lockout = (int)$lockouts['attempts_1']; $seconds_remaining_long_lockout = (int)$lockouts['duration_2'] * 60 - $time_since_last_fail; $seconds_remaining_short_lockout = (int)$lockouts['duration_1'] * 60 - $time_since_last_fail;
The next error was:
PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /dom25405/wp-content/plugins/authorizer/src/authorizer/class-wp-plugin-authorizer.php:222
The fix for this is a test for is_array():
'role' => is_array( $user->roles ) && count( $user->roles ) > 0 ? $user->roles[0] : 'administrator',
The fixes to the plugin appear to be working in our staging environment, but I’m hoping you can have an updated version ready soon. Thanks!
Regards,Mark Pemburn
Web Application Administrator
Clark University
Viewing 15 replies - 1 through 15 (of 15 total)
Viewing 15 replies - 1 through 15 (of 15 total)
- The topic ‘Fatal Errors under PHP 8.1’ is closed to new replies.