PHP Error in ShortcodeParser with PHP 8.1

[ad_1]

WordPress 6.1
ProfilePress 4.3.1
PHP 8.1

Hi,

we are upgrading to PHP 8.1 at the moment because the PHP 7.4 security support is ending in a few days. The switch to 8.1 was successful with WordPress 6.1 so far but the only plugin left that throws an error is ProfilePress :D.

The error occurs in that file:

wp-content/plugins/wp-user-avatar/src/ShortcodeParser/Builder/FieldsShortcodeCallback.php

on line 39

if (method_exists($this->current_user, 'exists') && $this->current_user->exists()) $flag = true;

this is the error message:

TypeError: method_exists(): Argument #1 ($object_or_class) must be of type object|string, null given

So it seems like $this->current_user is null at that point which throws the error. But the error is only thrown if we switch to PHP 8.1 – As soon as we switch back to 7.4 the error has gone away. Indeed method_exists() was updated in PHP8 and it now throws an error in such a case apparently.

It would be nice, if you could provide a fix for that in an upcoming version. Thank you very much.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer