jenkins-bot has submitted this change and it was merged.
Change subject: Reduce other projects sidebar initialization
......................................................................
Reduce other projects sidebar initialization
Don't attempt to initialize the sidebar if the current page
is not linked with any item.
Change-Id: I154a67310a8d7b4beb68b1930d9bbc290eb76c66
(cherry picked from commit 888a7f476a41710456fac41d3524a1434a934a9c)
---
M client/includes/hooks/SidebarHookHandlers.php
M client/tests/phpunit/includes/hooks/SidebarHookHandlersTest.php
2 files changed, 13 insertions(+), 3 deletions(-)
Approvals:
Aude: Looks good to me, approved
jenkins-bot: Verified
diff --git a/client/includes/hooks/SidebarHookHandlers.php
b/client/includes/hooks/SidebarHookHandlers.php
index a703555..ba86cdc 100644
--- a/client/includes/hooks/SidebarHookHandlers.php
+++ b/client/includes/hooks/SidebarHookHandlers.php
@@ -2,6 +2,7 @@
namespace Wikibase\Client\Hooks;
+use Action;
use OutputPage;
use ParserOutput;
use Skin;
@@ -211,7 +212,8 @@
$outputPage = $skin->getContext()->getOutput();
$title = $outputPage->getTitle();
- if ( !$this->namespaceChecker->isWikibaseEnabled(
$title->getNamespace() ) ) {
+ if ( !$this->namespaceChecker->isWikibaseEnabled(
$title->getNamespace() ) ||
+ !$outputPage->getProperty( 'wikibase_item' ) ) {
return true;
}
diff --git a/client/tests/phpunit/includes/hooks/SidebarHookHandlersTest.php
b/client/tests/phpunit/includes/hooks/SidebarHookHandlersTest.php
index 19a00b9..a8cf690 100644
--- a/client/tests/phpunit/includes/hooks/SidebarHookHandlersTest.php
+++ b/client/tests/phpunit/includes/hooks/SidebarHookHandlersTest.php
@@ -338,16 +338,18 @@
*
* @param boolean $enabled
* @param array|null $projects A list of projects
+ * @param string $itemId
*
* @return array The resulting sidebar array
*/
- private function callDoSidebarBeforeOutput( $enabled, $projects ) {
+ private function callDoSidebarBeforeOutput( $enabled, $projects,
$itemId = 'Q42' ) {
$title = Title::makeTitle( NS_MAIN, 'Oxygen' );
- $context = new RequestContext( new FauxRequest() );
+ $context = new RequestContext();
$output = new OutputPage( $context );
$output->setTitle( $title );
+ $output->setProperty( 'wikibase_item' , $itemId );
$output->setProperty( 'wikibase-otherprojects-sidebar',
$projects );
$context->setOutput( $output );
@@ -371,6 +373,12 @@
$this->assertEquals( $sidebar['wikibase-otherprojects'],
$projects );
}
+ public function testDoSidebarBeforeOutput_noItem() {
+ $sidebar = $this->callDoSidebarBeforeOutput( true, null, null );
+
+ $this->assertArrayNotHasKey( 'wikibase-otherprojects', $sidebar
);
+ }
+
public function testDoSidebarBeforeOutput_empty() {
$projects = array();
$sidebar = $this->callDoSidebarBeforeOutput( true, $projects );
--
To view, visit https://gerrit.wikimedia.org/r/180056
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I154a67310a8d7b4beb68b1930d9bbc290eb76c66
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: wmf/1.25wmf12c
Gerrit-Owner: Aude <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits