Jeroen De Dauw has uploaded a new change for review. https://gerrit.wikimedia.org/r/257855
Change subject: Remove string refs to function and make it non-public ...................................................................... Remove string refs to function and make it non-public Change-Id: Iacc9852a35f131327b3afbc2c890bab7faf7b977 --- M lib/includes/store/sql/SiteLinkTable.php 1 file changed, 24 insertions(+), 24 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/55/257855/1 diff --git a/lib/includes/store/sql/SiteLinkTable.php b/lib/includes/store/sql/SiteLinkTable.php index f224e49..31a3f22 100644 --- a/lib/includes/store/sql/SiteLinkTable.php +++ b/lib/includes/store/sql/SiteLinkTable.php @@ -63,28 +63,6 @@ } /** - * @param SiteLink $a - * @param SiteLink $b - * - * @return int - */ - public function compareSiteLinks( SiteLink $a, SiteLink $b ) { - $siteComp = strcmp( $a->getSiteId(), $b->getSiteId() ); - - if ( $siteComp !== 0 ) { - return $siteComp; - } - - $pageComp = strcmp( $a->getPageName(), $b->getPageName() ); - - if ( $pageComp !== 0 ) { - return $pageComp; - } - - return 0; - } - - /** * @see SiteLinkStore::saveLinksOfItem * * @since 0.1 @@ -98,8 +76,8 @@ $newLinks = $item->getSiteLinkList()->toArray(); $oldLinks = $this->getSiteLinksForItem( $item->getId() ); - $linksToInsert = array_udiff( $newLinks, $oldLinks, array( $this, 'compareSiteLinks' ) ); - $linksToDelete = array_udiff( $oldLinks, $newLinks, array( $this, 'compareSiteLinks' ) ); + $linksToInsert = $this->diffSiteLinks( $newLinks, $oldLinks ); + $linksToDelete = $this->diffSiteLinks( $oldLinks, $newLinks ); if ( !$linksToInsert && !$linksToDelete ) { wfDebugLog( __CLASS__, __FUNCTION__ . ": links did not change, returning." ); @@ -126,6 +104,28 @@ return $ok; } + private function diffSiteLinks( array $firstList, array $secondList ) { + return array_udiff( + $firstList, + $secondList, + function( SiteLink $a, SiteLink $b ) { + $siteComp = strcmp( $a->getSiteId(), $b->getSiteId() ); + + if ( $siteComp !== 0 ) { + return $siteComp; + } + + $pageComp = strcmp( $a->getPageName(), $b->getPageName() ); + + if ( $pageComp !== 0 ) { + return $pageComp; + } + + return 0; + } + ); + } + /** * Internal callback for inserting a list of links. * -- To view, visit https://gerrit.wikimedia.org/r/257855 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iacc9852a35f131327b3afbc2c890bab7faf7b977 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw <jeroended...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits