customLocale plugin error

I’m running ojs 3.1.2
Anybody else getting this error with the customLocale plugin (https://github.com/asmecher/customLocale):

PHP Fatal error: Uncaught Error: Call to a member function getId() on null in plugins/generic/customLocale/CustomLocalePlugin.inc.php:30

I modified line 30 to:
$context = Request::getContext();
$request = $this->getRequest();
$context = $request->getContext();
$contextId = $context->getId();

but still got the error: Call to a member function getId() on null

My only other thought was to test if the $context is set then proceed.

Is there a better solution?

Jeremy

Hi @jhennig,

Calls to $request->getContext() should return a Context object (a Journal in the case of OJS) for any request that’s within a journal’s “space”. If you’re getting a null back, as it appears you are, then you must be in a site-wide area. However, the custom locale plugin is coded to only be a journal-specific plugin, i.e. it should only be activated where $request->getContext will be set. Does any of this ring a bell? Is it possible that someone has intervened on your install to make the plugin active site-wide?

Regards,
Alec Smecher
Public Knowledge Project Team

Oh I see. Makes sense. yes another admin did enable it site wide.

Thanks.
Jeremy

Hell all, @asmecher, @jhennig,

I just happen to enable that plugin at site-wide level and OJS crashed.
I don’t know how to fix this… I hope that’s the problem, as an error is displayed when I try to run php tools/upgrade.php check to get some sort of error message…

PHP Fatal error:  Uncaught Error: Call to a member function getId() on null in /var/www/revista.ibict.br/plugins/generic/customLocale/CustomLocalePlugin.inc.php:32
Stack trace:
#0 /var/www/revista.ibict.br/lib/pkp/classes/plugins/PluginRegistry.inc.php(69): CustomLocalePlugin->register()
#1 /var/www/revista.ibict.br/lib/pkp/classes/plugins/PluginRegistry.inc.php(144): PluginRegistry::register()
#2 /var/www/revista.ibict.br/lib/pkp/classes/cliTool/CliTool.inc.php(65): PluginRegistry::loadCategory()
#3 /var/www/revista.ibict.br/lib/pkp/classes/cliTool/UpgradeTool.inc.php(35): CommandLineTool->__construct()
#4 /var/www/revista.ibict.br/tools/upgrade.php(21): UpgradeTool->__construct()
#5 {main}
  thrown in /var/www/revista.ibict.br/plugins/generic/customLocale/CustomLocalePlugin.inc.php on line 32

Sorry I can’t quite remember what I did as it was a while ago so I’m just a guessing here.
There is a sitewide field in the versions table you can try setting to 0.

Jeremy

I had the same error today.

I had to access the OJS database, go to the plugin_settings table, and looked for rows with plugin_name = customlocaleplugin. I deleted the row with context_id = 0.

Since this is a DB change, I suggest to backup the database first. Good luck!

Update: This fixed the site, but tools/upgrade.php still throws an error.