[MediaWiki-commits] [Gerrit] Put other project links in parser cache - change (mediawiki...Wikibase)

2014-09-05 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Put other project links in parser cache
..


Put other project links in parser cache

Bug: 70393
Change-Id: I25cc3ea4af94c77eb67ddc02a84df0d95e1348cc
---
M client/WikibaseClient.hooks.php
D client/includes/EntityIdPropertyUpdater.php
M client/includes/LangLinkHandler.php
M client/includes/WikibaseClient.php
M client/tests/phpunit/includes/LangLinkHandlerTest.php
5 files changed, 157 insertions(+), 96 deletions(-)

Approvals:
  Tobias Gritschacher: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/client/WikibaseClient.hooks.php b/client/WikibaseClient.hooks.php
index 83ae926..80b2bd4 100644
--- a/client/WikibaseClient.hooks.php
+++ b/client/WikibaseClient.hooks.php
@@ -346,7 +346,9 @@
return true;
}
 
-   if ( !self::isWikibaseEnabled( 
$parser->getTitle()->getNamespace() ) ) {
+   $title = $parser->getTitle();
+
+   if ( !self::isWikibaseEnabled( $title->getNamespace() ) ) {
// shorten out
return true;
}
@@ -355,8 +357,6 @@
 
// @todo split up the multiple responsibilities here and in 
lang link handler
 
-   $parserOutput = $parser->getOutput();
-
// only run this once, for the article content and not 
interface stuff
//FIXME: this also runs for messages in 
EditPage::showEditTools! Ugh!
if ( $parser->getOptions()->getInterfaceMessage() ) {
@@ -364,32 +364,26 @@
return true;
}
 
-   $wikibaseClient = WikibaseClient::getDefaultInstance();
-   $settings = $wikibaseClient->getSettings();
+   $langLinkHandler = 
WikibaseClient::getDefaultInstance()->getLangLinkHandler();
 
-   $langLinkHandler = new LangLinkHandler(
-   $settings->getSetting( 'siteGlobalID' ),
-   $wikibaseClient->getNamespaceChecker(),
-   $wikibaseClient->getStore()->getSiteLinkTable(),
-   $wikibaseClient->getSiteStore(),
-   $wikibaseClient->getLangLinkSiteGroup()
-   );
-
-   $useRepoLinks = $langLinkHandler->useRepoLinks( 
$parser->getTitle(), $parser->getOutput() );
+   $parserOutput = $parser->getOutput();
+   $useRepoLinks = $langLinkHandler->useRepoLinks( $title, 
$parserOutput );
 
try {
if ( $useRepoLinks ) {
// add links
-   $langLinkHandler->addLinksFromRepository( 
$parser->getTitle(), $parser->getOutput() );
+   $langLinkHandler->addLinksFromRepository( 
$title, $parserOutput );
}
 
-   $langLinkHandler->updateItemIdProperty( 
$parser->getTitle(), $parser->getOutput() );
+   $langLinkHandler->updateItemIdProperty( $title, 
$parserOutput );
+   $langLinkHandler->updateOtherProjectsLinksData( $title, 
$parserOutput );
} catch ( \Exception $e ) {
wfWarn( 'Failed to add repo links: ' . $e->getMessage() 
);
}
 
+   $settings = WikibaseClient::getDefaultInstance()->getSettings();
+
if ( $useRepoLinks || $settings->getSetting( 'alwaysSort' ) ) {
-   // sort links
$interwikiSorter = new InterwikiSorter(
$settings->getSetting( 'sort' ),
$settings->getSetting( 'interwikiSortOrders' ),
@@ -551,6 +545,12 @@
$out->setProperty( 'wikibase_item', $itemId );
}
 
+   $otherProjects = $pout->getExtensionData( 
'wikibase-otherprojects-sidebar' );
+
+   if ( $otherProjects !== null ) {
+   $out->setProperty( 'wikibase-otherprojects-sidebar', 
$otherProjects );
+   }
+
return true;
}
 
@@ -622,6 +622,13 @@
 * @return bool
 */
public static function onSidebarBeforeOutput( Skin $skin, array 
&$sidebar ) {
+   $outputPage = $skin->getContext()->getOutput();
+   $title = $outputPage->getTitle();
+
+   if ( !self::isWikibaseEnabled( $title->getNamespace() ) ) {
+   return true;
+   }
+
$wikibaseClient = WikibaseClient::getDefaultInstance();
$settings = $wikibaseClient->getSettings();
 
@@ -630,11 +637,15 @@
BetaFeatures::isFeatureEnabled( 
$skin->getUser(), 'wikibase-otherprojects' );
 
if ( $settings->getSetting( 'otherProjectsLinksByDefault' ) || 
$betaFeatureEnabled )

[MediaWiki-commits] [Gerrit] Put other project links in parser cache - change (mediawiki...Wikibase)

2014-09-04 Thread Aude (Code Review)
Aude has uploaded a new change for review.

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

Change subject: Put other project links in parser cache
..

Put other project links in parser cache

Bug: 70393
Change-Id: I25cc3ea4af94c77eb67ddc02a84df0d95e1348cc
---
M client/WikibaseClient.hooks.php
D client/includes/EntityIdPropertyUpdater.php
M client/includes/LangLinkHandler.php
M client/includes/WikibaseClient.php
M client/tests/phpunit/includes/LangLinkHandlerTest.php
5 files changed, 154 insertions(+), 95 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/81/158381/3

diff --git a/client/WikibaseClient.hooks.php b/client/WikibaseClient.hooks.php
index 83ae926..61aa95a 100644
--- a/client/WikibaseClient.hooks.php
+++ b/client/WikibaseClient.hooks.php
@@ -346,7 +346,9 @@
return true;
}
 
-   if ( !self::isWikibaseEnabled( 
$parser->getTitle()->getNamespace() ) ) {
+   $title = $parser->getTitle();
+
+   if ( !self::isWikibaseEnabled( $title->getNamespace() ) ) {
// shorten out
return true;
}
@@ -355,8 +357,6 @@
 
// @todo split up the multiple responsibilities here and in 
lang link handler
 
-   $parserOutput = $parser->getOutput();
-
// only run this once, for the article content and not 
interface stuff
//FIXME: this also runs for messages in 
EditPage::showEditTools! Ugh!
if ( $parser->getOptions()->getInterfaceMessage() ) {
@@ -364,32 +364,26 @@
return true;
}
 
-   $wikibaseClient = WikibaseClient::getDefaultInstance();
-   $settings = $wikibaseClient->getSettings();
+   $langLinkHandler = 
WikibaseClient::getDefaultInstance()->getLangLinkHandler();
 
-   $langLinkHandler = new LangLinkHandler(
-   $settings->getSetting( 'siteGlobalID' ),
-   $wikibaseClient->getNamespaceChecker(),
-   $wikibaseClient->getStore()->getSiteLinkTable(),
-   $wikibaseClient->getSiteStore(),
-   $wikibaseClient->getLangLinkSiteGroup()
-   );
-
-   $useRepoLinks = $langLinkHandler->useRepoLinks( 
$parser->getTitle(), $parser->getOutput() );
+   $parserOutput = $parser->getOutput();
+   $useRepoLinks = $langLinkHandler->useRepoLinks( $title, 
$parserOutput );
 
try {
if ( $useRepoLinks ) {
// add links
-   $langLinkHandler->addLinksFromRepository( 
$parser->getTitle(), $parser->getOutput() );
+   $langLinkHandler->addLinksFromRepository( 
$title, $parserOutput );
}
 
-   $langLinkHandler->updateItemIdProperty( 
$parser->getTitle(), $parser->getOutput() );
+   $langLinkHandler->updateItemIdProperty( $title, 
$parserOutput );
+   $langLinkHandler->updateOtherProjectsLinksData( $title, 
$parserOutput );
} catch ( \Exception $e ) {
wfWarn( 'Failed to add repo links: ' . $e->getMessage() 
);
}
 
if ( $useRepoLinks || $settings->getSetting( 'alwaysSort' ) ) {
-   // sort links
+   $settings = 
WikibaseClient::getDefaultInstance()->getSettings();
+
$interwikiSorter = new InterwikiSorter(
$settings->getSetting( 'sort' ),
$settings->getSetting( 'interwikiSortOrders' ),
@@ -551,6 +545,12 @@
$out->setProperty( 'wikibase_item', $itemId );
}
 
+   $otherProjects = $pout->getExtensionData( 
'wikibase-otherprojects-sidebar' );
+
+   if ( $otherProjects !== null ) {
+   $out->setProperty( 'wikibase-otherprojects-sidebar', 
$otherProjects );
+   }
+
return true;
}
 
@@ -630,9 +630,20 @@
BetaFeatures::isFeatureEnabled( 
$skin->getUser(), 'wikibase-otherprojects' );
 
if ( $settings->getSetting( 'otherProjectsLinksByDefault' ) || 
$betaFeatureEnabled ) {
-   $otherProjectsSidebarGenerator = 
$wikibaseClient->getOtherProjectsSidebarGenerator();
-   $title = $skin->getContext()->getTitle();
-   $otherProjectsSidebar = 
$otherProjectsSidebarGenerator->buildProjectLinkSidebar( $title );
+   $outputPage = $skin->getContext()->getOutput();
+   $otherProjectsSidebar = $outputPage->getProperty( 
'wikibase-otherprojects-sidebar' );