-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New events + some other misc changes #13388
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
Conversation
@@ -168,6 +169,8 @@ public static function setSitesFromArray($sites) | |||
|
|||
self::setSiteFromArray($idSite, $site); | |||
} | |||
|
|||
return $sites; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can a return value be avoided as it is a "set" method? what gets modified here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The event can modify the list of sites and this function is called in SitesManager API. So if we don't return here, the API output isn't affected by any changes in the event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if a plugin changes the name of a site, it will be reflected in the Site
class cache, but not in SitesManager API output (and thus not in, eg, the site selector).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to call Sites::getSites
instead of returning a value there? It is really not expected that a setter
method changes the value and returns a different value. Maybe getSites
would under circumstances return too many sites?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose it would work for getting all sites, but I don't think it would work when working w/ a subset of all sites (eg, getting one site or the pattern match sites method).
The alternative is to pass sites in by reference, but that could be a BC break. Personally I don't see an issue w/ it returning since it's not really setting a property but adding sites to a cache. Perhaps it would be better to rename this method to something like Site::addToSiteCache()
and keep Site::setSite()
as deprecated proxy to new method (for BC).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be still quite unexpected. Could we maybe expose the method triggerSetSitesEvent
somehow but possibly with a better name? Site::enrichSites
or something? The set method does currently two things, enriching plus setting. We only want the "enriching" part so could just expose that method? Wouldn't be too much better as you would maybe already expect to get a site "enriched". It also means the "enriching part" would happen twice and possibly lead to problems? So it might not be an option either.
So OK to use the regular set method as already done. Let's just add a comment to the method to make clear what is happening and I wonder if we should mark the method as deprecated plus internal or so but not too important maybe as long as there is a good comment.
248dea9
to
2b400cd
Compare
Updated. |
Didn't test the PR but if tests pass looks good to merge. |
* Add Access.modifyUserAccess event. * Add some template events & use request::process for LanguagesManager API. * Use the result of Sites.setSites in SitesManager API. * More comments for Site::setSitesFromArray(). * fixing plugin test.
* Add Access.modifyUserAccess event. * Add some template events & use request::process for LanguagesManager API. * Use the result of Sites.setSites in SitesManager API. * More comments for Site::setSitesFromArray(). * fixing plugin test.
Changes:
Access.modifyUserAccess
so plugins can directly edit user access w/o having to go to the DB.Request::process()
for some LanguagesManager API calls so events will execute for it.Site.setSites
event in the SitesManager API so the output will change. (this will change API output)