[MediaWiki-commits] [Gerrit] Remove duplicate method from ItemHandler - change (mediawiki...Wikibase)
Addshore has uploaded a new change for review. https://gerrit.wikimedia.org/r/88021 Change subject: Remove duplicate method from ItemHandler .. Remove duplicate method from ItemHandler Change-Id: Ia41d3be0449a5ce2ee0b8fbc928d14f732c0f857 --- M repo/includes/content/ItemHandler.php M repo/includes/specials/SpecialItemByTitle.php 2 files changed, 9 insertions(+), 37 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/21/88021/1 diff --git a/repo/includes/content/ItemHandler.php b/repo/includes/content/ItemHandler.php index 6416677..2a18ff5 100644 --- a/repo/includes/content/ItemHandler.php +++ b/repo/includes/content/ItemHandler.php @@ -8,26 +8,7 @@ /** * Content handler for Wikibase items. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * http://www.gnu.org/copyleft/gpl.html - * * @since 0.1 - * - * @file - * @ingroup WikibaseRepo - * * @licence GNU GPL v2+ * @author Jeroen De Dauw jeroended...@gmail.com * @author Daniel Kinzler @@ -95,7 +76,13 @@ */ public function getContentFromSiteLink( $siteId, $pageName ) { $id = $this-getIdForSiteLink( $siteId, $pageName ); - return $id === false ? null : WikibaseRepo::getDefaultInstance()-getEntityContentFactory()-getFromId( new EntityId( Item::ENTITY_TYPE, $id ) ); + + if ( $id === false ) { + return null; + } + + $eid = new EntityId( Item::ENTITY_TYPE, $id ); + return WikibaseRepo::getDefaultInstance()-getEntityContentFactory()-getFromId( $eid ); } /** @@ -111,21 +98,6 @@ */ public function getIdForSiteLink( $siteId, $pageName ) { return StoreFactory::getStore()-newSiteLinkCache()-getItemIdForLink( $siteId, $pageName ); - } - - /** -* Get the item corresponding to the provided site and title pair, or null if there is no such item. -* -* @since 0.1 -* -* @param string $siteId -* @param string $pageName -* -* @return ItemContent|null -*/ - public function getFromSiteLink( $siteId, $pageName ) { - $id = $this-getIdForSiteLink( $siteId, $pageName ); - return $id === false ? null : WikibaseRepo::getDefaultInstance()-getEntityContentFactory()-getFromId( new EntityId( Item::ENTITY_TYPE, $id ) ); } /** diff --git a/repo/includes/specials/SpecialItemByTitle.php b/repo/includes/specials/SpecialItemByTitle.php index 9ae1131..d7ba2ca 100644 --- a/repo/includes/specials/SpecialItemByTitle.php +++ b/repo/includes/specials/SpecialItemByTitle.php @@ -61,14 +61,14 @@ } $itemHandler = new ItemHandler(); - $itemContent = $itemHandler-getFromSiteLink( $siteId, $pageName ); + $itemContent = $itemHandler-getContentFromSiteLink( $siteId, $pageName ); // Do we have an item content, and if not can we try harder? if ( $itemContent === null Settings::get( 'normalizeItemByTitlePageNames' ) === true ) { // Try harder by requesting normalization on the external site $siteObj = \SiteSQLStore::newInstance()-getSite( $siteId ); if ( $siteObj instanceof Site ) { $pageName = $siteObj-normalizePageName( $page ); - $itemContent = $itemHandler-getFromSiteLink( $siteId, $pageName ); + $itemContent = $itemHandler-getContentFromSiteLink( $siteId, $pageName ); } } -- To view, visit https://gerrit.wikimedia.org/r/88021 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia41d3be0449a5ce2ee0b8fbc928d14f732c0f857 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Addshore addshorew...@gmail.com ___
[MediaWiki-commits] [Gerrit] Remove duplicate method from ItemHandler - change (mediawiki...Wikibase)
jenkins-bot has submitted this change and it was merged. Change subject: Remove duplicate method from ItemHandler .. Remove duplicate method from ItemHandler Change-Id: Ia41d3be0449a5ce2ee0b8fbc928d14f732c0f857 --- M repo/includes/content/ItemHandler.php M repo/includes/specials/SpecialItemByTitle.php 2 files changed, 11 insertions(+), 39 deletions(-) Approvals: Daniel Kinzler: Looks good to me, approved jenkins-bot: Verified diff --git a/repo/includes/content/ItemHandler.php b/repo/includes/content/ItemHandler.php index 6416677..4530ca0 100644 --- a/repo/includes/content/ItemHandler.php +++ b/repo/includes/content/ItemHandler.php @@ -8,26 +8,7 @@ /** * Content handler for Wikibase items. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * http://www.gnu.org/copyleft/gpl.html - * * @since 0.1 - * - * @file - * @ingroup WikibaseRepo - * * @licence GNU GPL v2+ * @author Jeroen De Dauw jeroended...@gmail.com * @author Daniel Kinzler @@ -95,7 +76,13 @@ */ public function getContentFromSiteLink( $siteId, $pageName ) { $id = $this-getIdForSiteLink( $siteId, $pageName ); - return $id === false ? null : WikibaseRepo::getDefaultInstance()-getEntityContentFactory()-getFromId( new EntityId( Item::ENTITY_TYPE, $id ) ); + + if ( $id === false ) { + return null; + } + + $entityId = new EntityId( Item::ENTITY_TYPE, $id ); + return WikibaseRepo::getDefaultInstance()-getEntityContentFactory()-getFromId( $entityId ); } /** @@ -111,21 +98,6 @@ */ public function getIdForSiteLink( $siteId, $pageName ) { return StoreFactory::getStore()-newSiteLinkCache()-getItemIdForLink( $siteId, $pageName ); - } - - /** -* Get the item corresponding to the provided site and title pair, or null if there is no such item. -* -* @since 0.1 -* -* @param string $siteId -* @param string $pageName -* -* @return ItemContent|null -*/ - public function getFromSiteLink( $siteId, $pageName ) { - $id = $this-getIdForSiteLink( $siteId, $pageName ); - return $id === false ? null : WikibaseRepo::getDefaultInstance()-getEntityContentFactory()-getFromId( new EntityId( Item::ENTITY_TYPE, $id ) ); } /** @@ -146,8 +118,8 @@ return null; } - $eid = new EntityId( Item::ENTITY_TYPE, $id ); - return WikibaseRepo::getDefaultInstance()-getEntityContentFactory()-getTitleForId( $eid ); + $entityId = new EntityId( Item::ENTITY_TYPE, $id ); + return WikibaseRepo::getDefaultInstance()-getEntityContentFactory()-getTitleForId( $entityId ); } /** diff --git a/repo/includes/specials/SpecialItemByTitle.php b/repo/includes/specials/SpecialItemByTitle.php index 9ae1131..d7ba2ca 100644 --- a/repo/includes/specials/SpecialItemByTitle.php +++ b/repo/includes/specials/SpecialItemByTitle.php @@ -61,14 +61,14 @@ } $itemHandler = new ItemHandler(); - $itemContent = $itemHandler-getFromSiteLink( $siteId, $pageName ); + $itemContent = $itemHandler-getContentFromSiteLink( $siteId, $pageName ); // Do we have an item content, and if not can we try harder? if ( $itemContent === null Settings::get( 'normalizeItemByTitlePageNames' ) === true ) { // Try harder by requesting normalization on the external site $siteObj = \SiteSQLStore::newInstance()-getSite( $siteId ); if ( $siteObj instanceof Site ) { $pageName = $siteObj-normalizePageName( $page ); - $itemContent = $itemHandler-getFromSiteLink( $siteId, $pageName ); + $itemContent = $itemHandler-getContentFromSiteLink( $siteId, $pageName ); }