Hi,
the Toolset Maps plugin is giving fatal error, when I try to edit a page with Beaver Builder, as on this page the get_current_screen() function returns null.
This is the error message in the log:
PHP Fatal error: Uncaught TypeError: method_exists(): Argument #1 ($object_or_class) must be of type object|string, null given in /wp-content/plugins/toolset-maps/includes/toolset-maps-views.class.php:298
I have fixed it by adding a new condition to your function in the mentioned line:
return ( $current_screen && method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() );
Please check the code and add a new condition to check if $current_screen is equal to null, because if it is, than the method_exists() function will return a fatal error.
Hi,
Thank you for contacting us and I'd be happy to assist.
I've performed some tests on my website with the Beaver Builder and Toolset Maps, but couldn't reproduce this error.
Can you please share the exact steps to reproduce this on a test website or share temporary admin login details, of a website where this can be seen?
Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.
regards,
Waqar
Hi Waqar,
to reproduce the issue, you only need to edit a page with Beaver Builder. If you can't reproduce it, I can create a staging install, where you can test it.
But even if you can not reproduce it, the mentioned code is missing a very important condition to check if $current_screen variable is not equal to null. So it must be fixed anyway.
Thanks for writing back and a staging website would be very helpful.
In theory, your suggestion makes sense, but this will allow me in narrowing down the difference between yours and my tests and escalate this with proper steps.
Note: I'm setting your next reply as private so that you can share temporary admin login details.
Thank you for sharing the staging website's details.
I see there are a number of other plugins active as well, which would explain, why I wasn't able to reproduce this on a clean test website.
Although the exact steps or cause for the failure of the existing condition is not clear, I've shared your code change recommendation internally for further review so that it can become even more fail-safe.
We appreciate you bringing this to our attention.
It is a staging site, so you can disable any other plugin to test this issue more deeply.
Thank you for the offer.
We had an internal discussion and due to the nature of your recommended change, it will most likely make it into future releases, without the need for any further investigation.