WSOD when I move to php8.1

Describe the issue or problem
As far as OJS 3.3.0-14 is now php8.1 full compliant, I moved one journal to this version… but I got a WSOD.

Checking logs I found the error was in my theme:

[php:error] [pid 52] [client 172.19.0.21:58606] 
PHP Fatal error:  Uncaught Error: Non-static method PKPApplication::getRequest() cannot be called statically in /var/www/html/plugins/themes/redi/rediThemePlugin.inc.php:153\n
Stack trace:\n#0 /var/www/html/lib/pkp/classes/plugins/HookRegistry.inc.php(107): rediThemePlugin->loadTemplateData()\n#1 /var/www/html/lib/pkp/classes/template/PKPTemplateManager.inc.php(1173): HookRegistry::call()\n#2 /var/www/html/pages/issue/IssueHandler.inc.php(85): PKPTemplateManager->display()\n#3 /var/www/html/lib/pkp/classes/core/PKPRouter.inc.php(395): IssueHandler->current()\n#4 /var/www/html/lib/pkp/classes/core/PKPPageRouter.inc.php(246): PKPRouter->_authorizeInitializeAndCallRequest()\n#5 /var/www/html/lib/pkp/classes/core/Dispatcher.inc.php(144): PKPPageRouter->route()\n#6 /var/www/html/lib/pkp/classes/core/PKPApplication.inc.php(362): Dispatcher->dispatch()\n#7 /var/www/html/index.php(75): PKPApplication->execute()\n#8 {main}\n  thrown in /var/www/html/plugins/themes/redi/rediThemePlugin.inc.php on line 153, referer: https://foo.org/demo/demo/about

What application are you using?

OJS 3.3.0-14

Solution

As is explained in the error “Non-static method PKPApplication::getRequest() cannot be called statically in /var/www/html/plugins/themes/redi/rediThemePlugin.inc.php”

In line 153 I found the offending call that is:

$request = Application::getRequest();    # This is wrong

It need to be replaced by:

$request = (new Application)->getRequest();

Hi @marc,

I have a slightly different recommendation:

Note that this is a problem with the “redi” theme, not the OJS 3.3.0-14 release.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

Sure, it’s completely my fault (my theme was not php8.1 compliant).

As the loadTemplate function is something taken from old theme examples, I just posted to help others in same situation.

But I’m curious. Very briefly (if not, just ignore me), what is the benefit of your approach related with the one I suggested?

Take care,
m.

Hi @marc,

If another part of the code alters the singleton instance of the Application class, that change won’t be apparent to a new instantiation.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

Sure. It’s obvious now that I read you.
Thanks.