customLocale plugin error

I’m running ojs 3.1.2
Anybody else getting this error with the customLocale plugin (

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

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?


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?

Alec Smecher
Public Knowledge Project Team

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


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/
Stack trace:
#0 /var/www/ CustomLocalePlugin->register()
#1 /var/www/ PluginRegistry::register()
#2 /var/www/ PluginRegistry::loadCategory()
#3 /var/www/ CommandLineTool->__construct()
#4 /var/www/ UpgradeTool->__construct()
#5 {main}
  thrown in /var/www/ 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.


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.