Page MenuHomePhabricator

Allow services to be injected into SecurePoll ActionPages
Closed, ResolvedPublic5 Estimated Story Points

Description

SecurePoll ActionPages often need to access services; however there is currently no way to inject them.

ActionPages are instantiated via SpecialSecurePoll::getSubPage:

public function getSubpage( $name ) {
	if ( !isset( self::$pages[$name] ) ) {
		return false;
	}
	$className = self::$pages[$name];

	return new $className( $this );
}

We could create an ActionPageFactory service, which could be injected into SpecialSecurePoll. This could use the ObjectFactory service to create a given ActionPage, according to spec.

Note that there are some other places where ActionPages are instantiated, e.g. ApiStrikeVote instantiates a ListPage. These should also use the new factory service.

Actually injecting the services could happen in separate follow-up tasks.

Further reading

Event Timeline

Change 667231 had a related patch set uploaded (by DLynch; owner: DLynch):
[mediawiki/extensions/SecurePoll@master] Make an ActionPageFactory service so ActionPages can do dependencies

https://gerrit.wikimedia.org/r/667231

Change 667232 had a related patch set uploaded (by DLynch; owner: DLynch):
[mediawiki/extensions/SecurePoll@master] Port CreatePage to have service dependencies

https://gerrit.wikimedia.org/r/667232

I can do all the other page-ports quite quickly, but I want to get the review on the service done first so I don't wind up having to change and rebase everything if any major changes are requested.

I can do all the other page-ports quite quickly, but I want to get the review on the service done first so I don't wind up having to change and rebase everything if any major changes are requested.

Thanks @DLynch - I've spun these out into separate tasks to use as onboarding work. Have assigned T276076: Port CreatePage to have service dependencies to you and referenced it from your commit, so we can use it as an example of how to do it.

Change 667231 merged by jenkins-bot:
[mediawiki/extensions/SecurePoll@master] Make an ActionPageFactory service so ActionPages can do dependencies

https://gerrit.wikimedia.org/r/667231

I think this one can skip QA -- it doesn't really have anything specific to test.