I am currently operating OPS3.3.0.8 (PHP7.4), but I plan to upgrade to PHP8.x soon.
Please tell me how to deal with PHP8 errors such as Deprecated errors and PHP Fatal errors (Uncaught TypeError, etc.) in PHP cache files created under the “./cache/t_compile/” directory.
I can fix the PHP cache file directly to temporarily deal with it, but when the cache file is regenerated, it will return to the original, so I would like to make a fundamental fix.
Dear @bozana , @asmecher,
Since this matter is very urgent and important for me, I have nominated you.
Do you have any advice or comments on this matter?
You can directly edit the source code, although this activity not recommended because will change the OJS/OPS source code that may lead to unexpected behavior in your OJS/OPS.
To be able to do this for example on this cache file :
Thank you for your advice.
I compared the cache file with the original template, but I don’t know how to fix the original template.
For example, if I want to add “(string)” to the parameter of the strstr function, I can add it to the cache file, but can I add it to the template file?
The better way to do it to copy paste it on your theme folder, for example on the plugins/themes/default/ copy paste the lib/pkp/template/form folder and place the textInput.tpl file on that folder.
You can edit or modify whatever you want, then after you have finish you can clear cache of your OJS by following this guide.
By doing above steps, you are not modify the original OJS source code.
If you in case the page that use the file show “white / blank” it means you have some error to the coding modification and you need to enable display_error = on on your OJS config.
However, I still recommend to use PHP 7.4 since OJS => 3.3.0.13 actually does not support PHP 8.
Thank you for your kind repley.
I understand how to test and debug it, but I’m not sure how to customize the Smarty template specifically.
Do you have any tips or advice on this?
In addition, please let me know the version of OJS/OPS that supports officially PHP 8.0 and PHP8.1.
The tips is using the child theme to override those tpl file from OJS/OPS.
On our experience the latest version of OJS/OPS does not fully compatible with PHP 8.
Based on our experience when handling hundred of client it is safe to say to use PHP 7.4 even on the latest version of OJS/OPS. You also need to take a consideration the ecosystem (plugins/third-party app) before decide to use PHP 8.
If possible, I would like to modify the php file and reflect it in the template instead of embedding the php code in the template file (.tpl). Is that possible?
Also, I heard earlier in this forum that OJS3.3/OPS3.3 is compatible with PHP8, but does that mean that it is not actually compatible?
Security support for PHP7.4 expires on November 28, 2022, so I need to complete PHP8 support by then.
So, I and my client are so pressed for time to upgrade to PHP8.
Yes it is possible to directly edit the file. I think the OJS will be support PHP8 on the later 3.3.0.14 version. On technical perspective it is better to wait for those version then upgrade your OJS. The expiration of security support does not mean that it has vulnerability right away on 22 Nov 2022.
However, you can try PHP 8 on your environment and let community know the issue here.
I don’t really want to embed PHP code in Smarty template files.
So, I would like to modify the PHP file side.
For some reasons on our side, we will not be able to update the OPS version for a while.
So, we are forced to update to PHP8.x with the current version.
Meanwhile, I really don’t recommend editing the .tpl.php files directly; you can use the appropriate Smarty syntax instead and edit the .tpl file. For example, try the |default:"" modifier to add a default value to a possibly null variable. But I suspect this has already been fixed in the latest release; I would recommend upgrading, and if you still encounter problems, post the full error here and I’ll be able to make a more specific recommendation.
Regards,
Alec Smecher
Public Knowledge Project Team
Thank you for your useful reply.
As I mentioned earlier, we are in a situation where it is difficult to upgrade OPS immediately, so we decided to upgrade PHP only.
So far, I have already modified some source files and template files in the development environment, but I didn’t know what to do about cache files that caused Deprecated errors, so I made this post.
As you instructed, when it comes to modifying the template, I will use Smarty syntax and edit the .tpl file while referring to the fix on Github.
If you are able to include the full error message and stack trace to go with each problem, I may be able to identify specific changes in the git commit history that you can apply.
Regards,
Alec Smecher
Public Knowledge Project Team
Thank you for your kind reply.
Some deprecated warning messages are also output in the sources under ./lib/pkp/lib/vendor/, but it seems that the modified sources for these are not posted on Github.
example.
PHP Deprecated: Function strftime() is deprecated in ./lib/pkp/lib/vendor/smarty/smarty/libs/plugins/modifier.date_format.php on line 81
PHP Deprecated: Function strftime() is deprecated in ./lib/pkp/lib/vendor/smarty/smarty/libs/plugins/function.html_select_date.php on line 312
PHP Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in ./lib/pkp/lib/vendor/smarty/smarty/libs/plugins/modifier.escape.php on line 39
PHP Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/html/ops/lib/pkp/lib/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer.php on line 312
I made a temporary fix here, but it would be helpful if you could let me know how to fix it officially.
(I wouldn’t normally choose to patch 3rd party dependencies, but it’s necessary in order to support both PHP8.1 and our baseline PHP7.3; there is no set of official dependencies that will support both of these intercompatibly.)
Regards,
Alec Smecher
Public Knowledge Project Team
Thank you for your useful information.
However, we have made many customizations to OPS and have completed support for PHP8.1, so we are unable to override the new OPS version files.
I think it’s a very bad situation, but we have no choice but to operate as it is for the time being.
I would like to improve this situation at some point.