jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/328490 )
Change subject: Remove misplaced namespace lookup method from EntityTitleStoreLookup ...................................................................... Remove misplaced namespace lookup method from EntityTitleStoreLookup Remove the namespace lookup from the title lookup interface. There was only one consumer. There is also code in EntityContentFactory that implements this namespace lookup method. This code is untouched. No caller needed the interface there. Bug: T152498 Change-Id: I1fec984d3bb89f52a6d599d49f9f617beb34731b --- M lib/includes/Store/EntityNamespaceLookup.php M repo/includes/Hooks/EditFilterHookRunner.php M repo/includes/Store/EntityTitleStoreLookup.php M repo/includes/WikibaseRepo.php M repo/tests/phpunit/includes/Hooks/EditFilterHookRunnerTest.php 5 files changed, 18 insertions(+), 15 deletions(-) Approvals: Daniel Kinzler: Looks good to me, approved jenkins-bot: Verified diff --git a/lib/includes/Store/EntityNamespaceLookup.php b/lib/includes/Store/EntityNamespaceLookup.php index 87355b7..d1922fe 100644 --- a/lib/includes/Store/EntityNamespaceLookup.php +++ b/lib/includes/Store/EntityNamespaceLookup.php @@ -17,7 +17,7 @@ * @author Adrian Heine <[email protected]> * @author Thiemo Mättig */ -final class EntityNamespaceLookup { +class EntityNamespaceLookup { /** * @var int[] diff --git a/repo/includes/Hooks/EditFilterHookRunner.php b/repo/includes/Hooks/EditFilterHookRunner.php index 2c962c1..57945b7 100644 --- a/repo/includes/Hooks/EditFilterHookRunner.php +++ b/repo/includes/Hooks/EditFilterHookRunner.php @@ -14,6 +14,7 @@ use Wikibase\DataModel\Entity\EntityDocument; use Wikibase\DataModel\Entity\EntityId; use Wikibase\DataModel\Entity\EntityRedirect; +use Wikibase\Lib\Store\EntityNamespaceLookup; use Wikibase\Repo\Store\EntityTitleStoreLookup; use Wikibase\Repo\Content\EntityContentFactory; use WikiPage; @@ -26,6 +27,11 @@ * @author Addshore */ class EditFilterHookRunner { + + /** + * @var EntityNamespaceLookup + */ + private $namespaceLookup; /** * @var EntityTitleStoreLookup @@ -43,11 +49,13 @@ private $context; /** + * @param EntityNamespaceLookup $namespaceLookup * @param EntityTitleStoreLookup $titleLookup * @param EntityContentFactory $entityContentFactory * @param IContextSource $context */ public function __construct( + EntityNamespaceLookup $namespaceLookup, EntityTitleStoreLookup $titleLookup, EntityContentFactory $entityContentFactory, IContextSource $context @@ -58,6 +66,7 @@ $context = new DerivativeContext( $context ); } + $this->namespaceLookup = $namespaceLookup; $this->titleLookup = $titleLookup; $this->entityContentFactory = $entityContentFactory; $this->context = $context; @@ -135,7 +144,7 @@ // "Special:NewProperty" instead of "Property:NewProperty", while // the AbuseFilter itself will get a Title object with the correct // namespace IDs for Property entities. - $namespace = $this->titleLookup->getNamespaceForType( $entityType ); + $namespace = $this->namespaceLookup->getEntityNamespace( $entityType ); $title = Title::makeTitle( $namespace, 'New' . ucfirst( $entityType ) ); } diff --git a/repo/includes/Store/EntityTitleStoreLookup.php b/repo/includes/Store/EntityTitleStoreLookup.php index 29e4ab6..0d4d597 100644 --- a/repo/includes/Store/EntityTitleStoreLookup.php +++ b/repo/includes/Store/EntityTitleStoreLookup.php @@ -2,7 +2,6 @@ namespace Wikibase\Repo\Store; -use OutOfBoundsException; use Wikibase\Lib\Store\EntityTitleLookup; /** @@ -19,17 +18,5 @@ * @author Thiemo Mättig */ interface EntityTitleStoreLookup extends EntityTitleLookup { - - /** - * Determines what namespace is suitable for the given type of entities. - * - * @since 0.5 - * - * @param string $entityType the entity type to look up, as returned by Entity::getType() - * - * @throws OutOfBoundsException - * @return int the namespace ID for this type - */ - public function getNamespaceForType( $entityType ); } diff --git a/repo/includes/WikibaseRepo.php b/repo/includes/WikibaseRepo.php index d2bf3fb..f89ddcc 100644 --- a/repo/includes/WikibaseRepo.php +++ b/repo/includes/WikibaseRepo.php @@ -652,6 +652,7 @@ */ private function newEditFilterHookRunner( IContextSource $context ) { return new EditFilterHookRunner( + $this->getEntityNamespaceLookup(), $this->getEntityTitleLookup(), $this->getEntityContentFactory(), $context diff --git a/repo/tests/phpunit/includes/Hooks/EditFilterHookRunnerTest.php b/repo/tests/phpunit/includes/Hooks/EditFilterHookRunnerTest.php index 1e00927..031ec1e 100644 --- a/repo/tests/phpunit/includes/Hooks/EditFilterHookRunnerTest.php +++ b/repo/tests/phpunit/includes/Hooks/EditFilterHookRunnerTest.php @@ -15,6 +15,7 @@ use Wikibase\DataModel\Entity\Item; use Wikibase\DataModel\Entity\ItemId; use Wikibase\ItemContent; +use Wikibase\Lib\Store\EntityNamespaceLookup; use Wikibase\Repo\Store\EntityTitleStoreLookup; use Wikibase\Repo\Content\EntityContentFactory; use Wikibase\Repo\Hooks\EditFilterHookRunner; @@ -39,6 +40,10 @@ $context = new RequestContext(); $context->setRequest( new FauxRequest() ); + $namespaceLookup = $this->getMockBuilder( EntityNamespaceLookup::class ) + ->disableOriginalConstructor() + ->getMock(); + $entityTitleLookup = $this->getMock( EntityTitleStoreLookup::class ); $entityTitleLookup->expects( $this->any() ) ->method( 'getTitleForId' ) @@ -62,6 +67,7 @@ ->will( $this->returnValue( ItemContent::newEmpty() ) ); return new EditFilterHookRunner( + $namespaceLookup, $entityTitleLookup, $entityContentFactory, $context -- To view, visit https://gerrit.wikimedia.org/r/328490 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I1fec984d3bb89f52a6d599d49f9f617beb34731b Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]> Gerrit-Reviewer: Addshore <[email protected]> Gerrit-Reviewer: Aleksey Bekh-Ivanov (WMDE) <[email protected]> Gerrit-Reviewer: Daniel Kinzler <[email protected]> Gerrit-Reviewer: WMDE-leszek <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
