Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Registration Notification] The plugin is mistakenly checking if it's active using the main context settings #6696

Open
jonasraoni opened this issue Jan 30, 2021 · 5 comments
Assignees
Labels
Bug:1:Minor A bug found in uncommon paths, with low consequences, limited users or has an easy workaround

Comments

@jonasraoni
Copy link
Contributor

Describe the bug
The plugin is checking if it's active using the "main context", but it's currently not a site-wide plugin.

What application are you using?
OJS 3.3

Additional information
$this->getEnabled($mainContextId)

@NateWr
Copy link
Contributor

NateWr commented Feb 1, 2021

I'm not certain, but I think the $mainContextId is a deprecated thing from OJS 2, where there was a multi-tier context system of some kind. The variable that is passed in here shouldn't reflect the "current context" as you would expect. I could be wrong, thoughh.

@asmecher
Copy link
Member

asmecher commented Feb 1, 2021

I'm not certain, but I think the $mainContextId is...

The reasoning for this is documented in LazyLoadPlugin::getEnabled:

	 * @param $contextId integer To identify if the plugin is enabled
	 *  we need a context. This context is usually taken from the
	 *  request but sometimes there is no context in the request
	 *  (e.g. when executing CLI commands). Then the main context
	 *  can be given as an explicit ID.

@ctgraham
Copy link
Collaborator

Interestingly, this makes a big difference when the plugin is a sitewide plugin. Currently, without a specific context passed in, a sitewide plugin will presume that getEnabled() wants to operate on CONTEXT_SITE.

public function getEnabled($contextId = null)
{
if ($contextId == null) {
$contextId = $this->getCurrentContextId();
if ($this->isSitePlugin()) {
$contextId = 0;
}
}
return $this->getSetting($contextId, 'enabled');
}

But generally (without addtional footwork in the plugin code) enabling a sitewide plugin will act on the specific context, leading to a bug like: pkp/shibboleth#3

The ability of a sitewide plugin to act specifically within a context is often desirable, so this leads to some crazy plugin code:
https://github.com/pkp/shibboleth/blob/3e59e58dcb09ed10e762c073365928bcb9dc05f3/ShibbolethAuthPlugin.inc.php#L27-L43

https://github.com/pkp/shibboleth/blob/3e59e58dcb09ed10e762c073365928bcb9dc05f3/ShibbolethAuthPlugin.inc.php#L178-L205

@asmecher
Copy link
Member

@ctgraham, do you think this might be the same issue as #6137?

@ctgraham
Copy link
Collaborator

I think it is certainly a fork of the endless morass of #1923 .

@jonasraoni jonasraoni changed the title [Plugin][Registration Notification] The plugin is mistakenly checking if it's active using the main context settings [Registration Notification] The plugin is mistakenly checking if it's active using the main context settings May 31, 2022
@jonasraoni jonasraoni added the Bug:1:Minor A bug found in uncommon paths, with low consequences, limited users or has an easy workaround label May 31, 2022
@jonasraoni jonasraoni moved this to Backlog in Plugins and Themes May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug:1:Minor A bug found in uncommon paths, with low consequences, limited users or has an easy workaround
Projects
Status: Backlog
Development

No branches or pull requests

4 participants