ojsde / shariff

The Shariff plugin adds social media buttons to the website without compromising the privacy of website users, using Shariff (https://github.com/heiseonline/shariff) solution.
GNU General Public License v3.0
9 stars 16 forks source link

Enabling the plugin in the site context breaks the index #13

Closed tgc closed 4 years ago

tgc commented 6 years ago

We just had downtime on our OJS3 index page and upon investigation I found this in the error log: PHP Fatal error: Call to a member function getId() on null in /srv/ojs/webroot/plugins/generic/shariff/ShariffPlugin.inc.php on line 42

I immediately suspected that it might have been enabled somewhere inappropriate and looking at the database I found an entry in the plugin_settings table where shariffplugin had been enabled for context_id=0. This can happen if the plugin is enabled in the site context which is very tempting for a site admin to do. To resolve the issue I removed the offending row in the plugin_settings table, but it would be nice if enabling it in the site context didn't trigger a fatal error requiring DB surgery to fix.

I am running OJS 3.1.1-2 and shariff from the v3_0_0 tag.

dennmuel commented 6 years ago

Just a quick comment: I guess this is not specific to Shariff. We've had this kind of behaviour in our instance with other plugins, too (can't remember which though). So perhaps this needs to be adressed in pkp/ojs or pkp/lib-pkp by introducing some kind of switch or mechanism to distinguish between plugins that can be used on index sites and those that can't.