Aude has uploaded a new change for review. https://gerrit.wikimedia.org/r/263433
Change subject: Require IContextSource as constructor param in EditFilterHookRunner ...................................................................... Require IContextSource as constructor param in EditFilterHookRunner In places that I see, this always is provided already to the constructor. The hook expects IContextSource when it is run. Context is also always provided for WikibaseRepo::getApiHelperFactory, so we can remove the option of that being null there. WikibaseRepo::newEditEntityFactory sometimes has $context as null (from UpdateRepoOnDelete etc.) so we can allow that, and then default to RequestContext::getMain there. Change-Id: I3e82e8ff31d89930313c59a366214ea9faa2df53 --- M repo/includes/Hooks/EditFilterHookRunner.php M repo/includes/WikibaseRepo.php 2 files changed, 16 insertions(+), 19 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/33/263433/1 diff --git a/repo/includes/Hooks/EditFilterHookRunner.php b/repo/includes/Hooks/EditFilterHookRunner.php index 0c482c0..07fe2a2 100644 --- a/repo/includes/Hooks/EditFilterHookRunner.php +++ b/repo/includes/Hooks/EditFilterHookRunner.php @@ -2,11 +2,9 @@ namespace Wikibase\Repo\Hooks; -use DerivativeContext; use Hooks; use IContextSource; use InvalidArgumentException; -use RequestContext; use RuntimeException; use Status; use Title; @@ -38,26 +36,20 @@ private $entityContentFactory; /** - * @var RequestContext|DerivativeContext + * @var IContextSource */ private $context; + /** + * @param EntityTitleLookup $titleLookup + * @param EntityContentFactory $entityContentFactory + * @param IContextSource $context + */ public function __construct( EntityTitleLookup $titleLookup, EntityContentFactory $entityContentFactory, - $context = null + IContextSource $context ) { - if ( $context !== null - && !( $context instanceof RequestContext ) - && !( $context instanceof DerivativeContext ) ) { - throw new InvalidArgumentException( '$context must be an instance of RequestContext' - . ' or DerivativeContext' ); - } - - if ( $context === null ) { - $context = RequestContext::getMain(); - } - $this->titleLookup = $titleLookup; $this->entityContentFactory = $entityContentFactory; $this->context = $context; diff --git a/repo/includes/WikibaseRepo.php b/repo/includes/WikibaseRepo.php index 3297c5f..cfe6ca3 100644 --- a/repo/includes/WikibaseRepo.php +++ b/repo/includes/WikibaseRepo.php @@ -12,6 +12,7 @@ use IContextSource; use Language; use MediaWiki\Site\MediaWikiPageNameNormalizer; +use RequestContext; use Serializers\Serializer; use SiteSQLStore; use SiteStore; @@ -520,11 +521,11 @@ } /** - * @param IContextSource|null $context + * @param IContextSource $context * * @return EditFilterHookRunner */ - private function newEditFilterHookRunner( IContextSource $context = null ) { + private function newEditFilterHookRunner( IContextSource $context ) { return new EditFilterHookRunner( $this->getEntityTitleLookup(), $this->getEntityContentFactory(), @@ -1296,11 +1297,11 @@ } /** - * @param IContextSource|null $context + * @param IContextSource $context * * @return ApiHelperFactory */ - public function getApiHelperFactory( IContextSource $context = null ) { + public function getApiHelperFactory( IContextSource $context ) { return new ApiHelperFactory( $this->getEntityTitleLookup(), $this->getExceptionLocalizer(), @@ -1319,6 +1320,10 @@ * @return EditEntityFactory */ public function newEditEntityFactory( IContextSource $context = null ) { + if ( $context === null ) { + $context = RequestContext::getMain(); + } + return new EditEntityFactory( $this->getEntityTitleLookup(), $this->getEntityRevisionLookup( 'uncached' ), -- To view, visit https://gerrit.wikimedia.org/r/263433 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3e82e8ff31d89930313c59a366214ea9faa2df53 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Aude <aude.w...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits