pkp / pkp-docs

A repository for generating PKP's documentation hub.
15 stars 247 forks source link

OJS 3.4 compatibility issue #1124

Closed m-amin-salem closed 1 year ago

m-amin-salem commented 1 year ago

I used a custom made plugin that works fine with OJS 3.X. When I installed the OJS 3.4 on the server, and tried to install the plugin, I got this error:

PHP Fatal error:  Uncaught Error: Class "AppLocale" not found in /app/plugins/generic/My_plugin/MyPlugin.inc.php:105

and this is the line 105 in my MyPlugin.inc.php:

AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON,  LOCALE_COMPONENT_PKP_MANAGER);

This error occoures because the code in the My_plugin is trying to use the class “AppLocale,” but it cannot findit because it's deprecated in 3.4 version, here is a comment in \APP\i18n\AppLocale::

@deprecated The class \APP\i18n\AppLocale has been replaced by PKP\facades\Locale

Accordingly, I have tried to use in /app/plugins/generic/My_plugin/MyPlugin.inc.php something like:

use PKP\facades\Locale;
use PKP\i18n\PKPLocale;

Locale::requireComponents(PKPLocale::LOCALE_COMPONENT_APP_COMMON, PKPLocale::LOCALE_COMPONENT_APP_MANAGER);

but I got this error:

NOTICE: PHP message: PHP Fatal error:  Uncaught Error: Undefined constant PKP\i18n\PKPLocale::LOCALE_COMPONENT_APP_COMMON in /app/plugins/generic/My_plugin/MyPlugin.inc.php:114

I'm not familiar with PHP and I'm not sure if I'm doing it right, but I believe the main issue now is how to import constants LOCALE_COMPONENT_APP_COMMON and LOCALE_COMPONENT_APP_MANAGER according to the new structure

m-amin-salem commented 1 year ago

Hey @jonasraoni do you have any idea about it or how should I approach it?

jonasraoni commented 1 year ago

This code is supposed to be working. It's just deprecated, we're not going to remove it yet.

Check if you have this setting on your config.inc.php: https://github.com/pkp/ojs/blob/5afc534f7e7cf67ce6c63e45c2300052687c2ec8/config.TEMPLATE.inc.php#L36


On another hand, if you opt to update the code, you can just remove the requireComponents(), as it's not needed anymore.

I'll close this issue because this isn't the right place to ask this, you can use the forum (https://forum.pkp.sfu.ca) if you still have doubts (feel free to tag me there, I use the same username everywhere).

jonasraoni commented 1 year ago

Oh, I can't close the issue, tagging @asmecher 😁

m-amin-salem commented 1 year ago

@jonasraoni No worries, I will close it, thanks a lot for your guidance