OJS 3 theme is not working in PHP 7

Hello to you all.

We have this problem in which our theme is working just fine in our production site, but this site is runing on PHP 5.6, which is outdated.

We want to upgrade to PHP 7, and we had install OJS 3.1.2 with PHP 7.2 in our dev site.

The problem comes in the public site of our dev site. There’s no frontend at all. I have tried like 5 different themes for OJS 3.1.1+ or 3.1+ that I saw in another thread, but none of those are working.

There’s a guide to develop a new theme for OJS 3.1.2+? Or there’s something that we need to know or change for the theme to work?

Thanks in advance.

Hi!
Can You check with default theme of the OJS (to rule out any issue with the theme itself) and driver setting in config.inc.php file under ::database settings:: driver = mysqli

Hi there,

OJS 3.1.2 introduced Smarty V3 and so many themes needed a rework and small modifications to get working correctly again. You may want to look in your PHP error logs to find out what the cause is, exactly.

Cheers
Jason

Hello, Jason!

Thank you very much!

I’ve reviewed our PHP error logs but there’s only one Warning but I don’t think that this warning is causing the site to breakdown… There’s a guide to make a rework of our themes with Smarty V3 that you can handle me, please?

Cheers
Daniel

Hi @daniel.anez,

If it’s a Smarty error, there should be appropriate mention in the log. On the top of my mind, in Smarty 3 was excluded {php} tag and several built-in functions renamed, like get_template_vars to getTemplateVars. Some info can be found here: https://raw.githubusercontent.com/smarty-php/smarty/master/SMARTY_2_BC_NOTES.txt. But once again, all incompatibilities should be reflected in PHP logs. You can also check the level of error reporting in php.ini.

Are you trying to run official themes or custom ones?

Hello @Vitaliy,

I was trying at first with one of our custom themes, but recently I tried with themes that I found on a Thread here in the forum and those doesn’t work either.

The only message related to a PHP error on the logs is:
AH01071: Got error 'PHP message: PHP Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/test.summapsicologica.cl/httpdocs/cache/t_compile/65bfc3e024c2e9104f46e23b73376a9455e3df0e^51cfb9321c891ada9323e7942962579e7e4324d1_0.app.frontendpagesindexSite.tp.php on line 43\n'

Is this the reason for the siteto breakdown?

Thanks in advance,
Daniel.

This warning shouldn’t cause the problem that you describe.

Hi @daniel.anez

Apologies, I was travelling. Looking back to your original post, when you say “no front end at all”, do you mean completely blank pages, or just unstyled content? Unstyled content may mean something other than your theme not being compatible with 3.1.2. Does the very basic default OJS 3 theme work if it is enabled?

Cheers,
Jason

Hi Jason!

Sorry, I had been working in other projects.

You’re right, there’s content on the pages but it’s unstyled content. The default OJS 3 theme does work correctly, but none of the others work. We’re reviewing the code for changes in the Smarty syntax.

Hi Jason!

Update: The default theme is no longer working.

Do you know if this issue have been fixed in OJS 3.1.2.4?

Hi @daniel.anez

The default theme should definitely work in 3.1.2.4. It’s part of the OJS core. I’d try clearing caches first, and looking in your error logs for detailed PHP problems. When you jumped to 3.1.2.4 did you also increase your PHP version? 3.1.2.4 requires PHP7.2. Older versions of OJS got by with PHP5.6.

Cheers,
Jason

Hi Jason!

Yes, we’re running the dev site with PHP 7.2, the default theme is running fine since I change de Plugin.inc.php to the one you have on your git.

The problem are the other themes, none of theme is working and the Smarty Doc is not public, so we’re searching for others solutions.

For example, the OJS themes that I found on a thread here in the forum doesn’t work and we don’t know why.

I’ve deleted the caches but that doesn’t solve the problem.

Hi @daniel.anez

Off the top of my head, the main thing that broke in older themes when Smarty was updated to version 3 were places where the template included embedded PHP code, like

{php}break;{/break}

or

{php}continue;{/continue}

Those needed to be changed to the Smarty equivalents, like {break} and {continue}.

This sort of thing would show up in the PHP error log, though. Anything in there at all?

Cheers,
Jason

Hi @jnugent

Happy new year!

I’m reviewing the code but in the error logs there’s no error related to PHP, just warnings like

AH01071: Got error 'PHP message: PHP Warning: Invalid argument supplied for foreach() in /var/www/vhosts/test.summapsicologica.cl/httpdocs/lib/pkp/classes/template/PKPTemplateManager.inc.php on line 1581\n

PHP message: PHP Warning: Invalid argument supplied for foreach() in /var/www/vhosts/test.summapsicologica.cl/httpdocs/lib/pkp/classes/template/PKPTemplateManager.inc.php on line 1581\n', referer: http://test.summapsicologica.cl/index.php/summatest/login

Hey @daniel.anez

If you’re getting unstyled content, but not blank pages, PHP isn’t generating fatal errors, so it’s probably the theme itself, not being loaded. Out of curiosity, what version of OJS are you using?

Cheers,
Jason

Hi @jnugent

We’re using OJS 3.1.2.

The only theme that works is the default theme. There’s no other theme working on the devsite (in which we’re working). The devsite is running in Plesk with PHP 7.2.

Which version of 3.1.2, though? 3.1.2 came out nearly a year ago, and there have been point releases for it as recent as just a few weeks ago. Lots of bug fixes since the first version :slight_smile:
Cheers,
Jason

And also, how exactly are you installing themes?

Cheers,
Jason

Hello @jnugent

I was trying to login to te site but I can’t. The user and pass are both correct (change the pass througt email) and the problem remains, I can’t acces to the admin dashboard.

We haven’t done any change on the code.

We have OJS 3.1.2.1 and I’m dowloading the themes, loading into the /plugins/theme folder, unzip it and then selecting them within the admin dashboard.

This is the error that shows the logs

AH01071: Got error 'PHP message: PHP Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/test.summapsicologica.cl/httpdocs/cache/t_compile/65bfc3e024c2e9104f46e23b73376a9455e3df0e^51cfb9321c891ada9323e7942962579e7e4324d1_0.app.frontendpagesindexSite.tp.php on line 43\n', referer: http://test.summapsicologica.cl/index.php/index/login