Smarty fatal error on new server

I’m trying to move an OJS installation from one server to another.

The old server is running PHP 7.4, the new one PHP 8.3.

I’ve exported the old server’s database and imported it on the new site, I’ve installed OJS 3.3.0-21 on the new site, and I’ve set the permissions up correctly. I ran the php tools/upgrade.php upgrade.

When I go to the site, the home page loads properly, but if I try to click into either of the two journals hosted on the server, I get a 500 error and the following turns up in the Apache error log:

PHP Fatal error:  Uncaught TypeError: Cannot access offset of type string on string in /srv/www/vhosts/journals.example.com/ojs-3.3.0-21/cache/t_compile/00a0a0910209607cb33eb0fe6474f30ed7399ed7^10ae5578a0959129b8d4ceeb9f99c1bb2a9cbd65_0.app.frontendcomponentsheader.tpl.php:79
Stack trace:
#0 /srv/www/vhosts/journals.example.com/ojs-3.3.0-21/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_68fa8c07e504b2_59040486()#1 /srv/www/vhosts/journals.example.com/ojs-3.3.0-21/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode()
#2 /srv/www/vhosts/journals.example.com/ojs-3.3.0-21/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(217): Smarty_Template_Compiled->render()
#3 /srv/www/vhosts/journals.example.com/ojs-3.3.0-21/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(386): Smarty_Internal_Template->render()
#4 /srv/www/vhosts/journals.example.com/ojs-3.3.0-21/cache/t_compile/00a0a0910209607cb33eb0fe6474f30ed7399ed7^e64e579388e5615e11e939b12134d6ae8679eba6_0.app.frontendpagesindexJournal.tpl.php(29): Smarty_Internal_Template->_subTemplateRender()
#5 /srv/www/vhosts/journals.example.com/ojs-3.3.0-21/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_68fa8c07e3d6e6_15029933()#6 /srv/www/vhosts/journals.example.com/ojs-3.3.0-21/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode()
#7 /srv/www/vhosts/journals.example.com/ojs-3.3.0-21/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(217): Smarty_Template_Compiled->render()
#8 /srv/www/vhosts/journals.example.com/ojs-3.3.0-21/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(238): Smarty_Internal_Template->render()#9 /srv/www/vhosts/journals.example.com/ojs-3.3.0-21/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(134): Smarty_Internal_TemplateBase->_execute()
#10 /srv/www/vhosts/journals.example.com/ojs-3.3.0-21/lib/pkp/classes/template/PKPTemplateManager.inc.php(1250): Smarty_Internal_TemplateBase->display()
#11 /srv/www/vhosts/journals.example.com/ojs-3.3.0-21/pages/index/IndexHandler.inc.php(67): PKPTemplateManager->display() 
#12 /srv/www/vhosts/journals.example.com/ojs-3.3.0-21/lib/pkp/classes/core/PKPRouter.inc.php(397): IndexHandler->index()
#13 /srv/www/vhosts/journals.example.com/ojs-3.3.0-21/lib/pkp/classes/core/PKPPageRouter.inc.php(246): PKPRouter->_authorizeInitializeAndCallRequest()
#14 /srv/www/vhosts/journals.example.com/ojs-3.3.0-21/lib/pkp/classes/core/Dispatcher.inc.php(144): PKPPageRouter->route()
#15 /srv/www/vhosts/journals.example.com/ojs-3.3.0-21/lib/pkp/classes/core/PKPApplication.inc.php(360): Dispatcher->dispatch()
#16 /srv/www/vhosts/journals.example.com/ojs-3.3.0-21/index.php(68): PKPApplication->execute()
#17 {main}
  thrown in /srv/www/vhosts/journals.example.com/ojs-3.3.0-21/cache/t_compile/00a0a0910209607cb33eb0fe6474f30ed7399ed7^10ae5578a0959129b8d4ceeb9f99c1bb2a9cbd65_0.app.frontendcomponentsheader.tpl.php on line 79, referer: https://journals.example.com/

It seems like Smarty isn’t behaving properly; I’m not sure, but it could be a PHP 8 issue.

Any suggestions?

Hi @pjohanneson,

Can you check in the database to see what the pageHeaderLogoImage setting looks like? I suspect this is a data error that was resulting in a warning in PHP 7.4, but now has been upgraded to an error in PHP 8.3. Try the following SQL query:

SELECT * FROM journal_settings WHERE setting_name='pageHeaderLogoImage';

Regards,
Alec Smecher
Public Knowledge Project Team

+------------+--------+---------------------+------------------------------------------------------------------------------------------------------------------------------------+--------------+
| journal_id | locale | setting_name        | setting_value                                                                                                                      | setting_type |
+------------+--------+---------------------+------------------------------------------------------------------------------------------------------------------------------------+--------------+
|          1 |        | pageHeaderLogoImage | {"name":"ojs_logo_default.gif","uploadName":"pageHeaderLogoImage.gif","width":57,"height":40,"dateUploaded":"2015-09-01 14:33:25"} | object       |
+------------+--------+---------------------+------------------------------------------------------------------------------------------------------------------------------------+--------------+

Hi @pjohanneson,

The pageHeaderLogoImage setting should be localized, but I see the locale column is empty. Assuming your journal is primarily English, try changing locale to en_US for that setting. (Make sure you back up your database before making changes directly there.)

Then, you may need to flush your data cache as Site Administrator before the error goes away.

Regards,
Alec Smecher
Public Knowledge Project Team

I think that’s got it. Thanks!

1 Like

This topic was automatically closed after 9 days. New replies are no longer allowed.