Thiemo Mättig (WMDE) has uploaded a new change for review.
https://gerrit.wikimedia.org/r/179135
Change subject: Fall back to page title if wikibase-titletext is n/a
......................................................................
Fall back to page title if wikibase-titletext is n/a
Change-Id: Ic20c54407447e517e3fd7926060c0bc85013892a
---
M client/includes/Usage/ParserOutputUsageAccumulator.php
M client/includes/hooks/SidebarHookHandlers.php
M repo/Wikibase.hooks.php
M repo/includes/EntityParserOutputGenerator.php
M repo/includes/actions/EditEntityAction.php
M repo/includes/actions/ViewEntityAction.php
6 files changed, 17 insertions(+), 25 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/35/179135/1
diff --git a/client/includes/Usage/ParserOutputUsageAccumulator.php
b/client/includes/Usage/ParserOutputUsageAccumulator.php
index 59b1528..2a272e2 100644
--- a/client/includes/Usage/ParserOutputUsageAccumulator.php
+++ b/client/includes/Usage/ParserOutputUsageAccumulator.php
@@ -47,7 +47,7 @@
*/
public function getUsages() {
$usages = $this->parserOutput->getExtensionData(
'wikibase-entity-usage' );
- return $usages === null ? array() : $usages;
+ return $usages ?: array();
}
/**
diff --git a/client/includes/hooks/SidebarHookHandlers.php
b/client/includes/hooks/SidebarHookHandlers.php
index 51ab7c7..5c8b497 100644
--- a/client/includes/hooks/SidebarHookHandlers.php
+++ b/client/includes/hooks/SidebarHookHandlers.php
@@ -147,25 +147,21 @@
}
$noExternalLangLinks =
NoLangLinkHandler::getNoExternalLangLinks( $parserOutput );
-
if ( !empty( $noExternalLangLinks ) ) {
$out->setProperty( 'noexternallanglinks',
$noExternalLangLinks );
}
$itemId = $parserOutput->getProperty( 'wikibase_item' );
-
if ( $itemId !== false ) {
$out->setProperty( 'wikibase_item', $itemId );
}
$otherProjects = $parserOutput->getExtensionData(
'wikibase-otherprojects-sidebar' );
-
if ( $otherProjects !== null ) {
$out->setProperty( 'wikibase-otherprojects-sidebar',
$otherProjects );
}
$badges = $parserOutput->getExtensionData( 'wikibase_badges' );
-
if ( $badges !== null ) {
$out->setProperty( 'wikibase_badges', $badges );
}
diff --git a/repo/Wikibase.hooks.php b/repo/Wikibase.hooks.php
index fceee04..7681057 100644
--- a/repo/Wikibase.hooks.php
+++ b/repo/Wikibase.hooks.php
@@ -956,19 +956,18 @@
* @return bool
*/
public static function onOutputPageParserOutput( OutputPage $out,
ParserOutput $parserOutput ) {
+ // Set in EntityParserOutputGenerator.
$placeholders = $parserOutput->getExtensionData(
'wikibase-view-chunks' );
-
- if ( $placeholders ) {
+ if ( $placeholders !== null ) {
$out->setProperty( 'wikibase-view-chunks',
$placeholders );
}
- // used in ViewEntityAction and EditEntityAction to override
the page html title
+ // Used in ViewEntityAction and EditEntityAction to override
the page HTML title
// with the label, if available, or else the id. Passed via
parser output
// and output page to save overhead of fetching content and
accessing an entity
// on page view.
$titleText = $parserOutput->getExtensionData(
'wikibase-titletext' );
-
- if ( $titleText ) {
+ if ( $titleText !== null ) {
$out->setProperty( 'wikibase-titletext', $titleText );
}
@@ -988,7 +987,7 @@
public static function onOutputPageBeforeHTML( OutputPage $out, &$html
) {
$placeholders = $out->getProperty( 'wikibase-view-chunks' );
- if ( $placeholders ) {
+ if ( !empty( $placeholders ) ) {
$injector = new TextInjector( $placeholders );
$userLanguageLookup = new UserLanguageLookup();
$expander = new EntityViewPlaceholderExpander(
diff --git a/repo/includes/EntityParserOutputGenerator.php
b/repo/includes/EntityParserOutputGenerator.php
index cf389f5..23fba58 100644
--- a/repo/includes/EntityParserOutputGenerator.php
+++ b/repo/includes/EntityParserOutputGenerator.php
@@ -2,7 +2,6 @@
namespace Wikibase;
-use OutOfBoundsException;
use ParserOutput;
use Wikibase\DataModel\Entity\Entity;
use Wikibase\DataModel\Entity\Item;
@@ -259,7 +258,7 @@
} else {
$entityId = $entity->getId();
- if ( !$entityId ) {
+ if ( $entityId === null ) {
return;
}
diff --git a/repo/includes/actions/EditEntityAction.php
b/repo/includes/actions/EditEntityAction.php
index e4970e5..901109d 100644
--- a/repo/includes/actions/EditEntityAction.php
+++ b/repo/includes/actions/EditEntityAction.php
@@ -276,7 +276,6 @@
/**
* @var EntityContent $latestContent
- * @var EntityContent $olderContent
* @var EntityContent $newerContent
*/
$olderContent = $olderRevision->getContent();
@@ -343,7 +342,7 @@
}
/**
- * Used for overriding the page html title with the label, if
available, or else the id.
+ * Used for overriding the page HTML title with the label, if
available, or else the id.
* This is passed via parser output and output page to save overhead on
view / edit actions.
*
* @return string
@@ -352,7 +351,7 @@
$titleText = $this->getOutput()->getProperty(
'wikibase-titletext' );
if ( $titleText === null ) {
- $titleText = '';
+ $titleText = $this->getTitle()->getPrefixedText();
}
return $titleText;
diff --git a/repo/includes/actions/ViewEntityAction.php
b/repo/includes/actions/ViewEntityAction.php
index 4e36631..3f343e6 100644
--- a/repo/includes/actions/ViewEntityAction.php
+++ b/repo/includes/actions/ViewEntityAction.php
@@ -9,7 +9,6 @@
use SpecialPage;
use ViewAction;
use Wikibase\Repo\Content\EntityHandler;
-use Wikibase\Repo\WikibaseRepo;
/**
* Handles the view action for Wikibase entities.
@@ -111,7 +110,7 @@
$titleText = $this->getOutput()->getProperty(
'wikibase-titletext' );
if ( $titleText === null ) {
- return;
+ $titleText = $this->getTitle()->getPrefixedText();
}
if ( $this->isDiff() ) {
@@ -123,9 +122,9 @@
/**
* @param OutputPage $outputPage
- * @param string $labelText
+ * @param string $titleText
*/
- private function setPageTitle( OutputPage $outputPage, $labelText ) {
+ private function setPageTitle( OutputPage $outputPage, $titleText ) {
// Escaping HTML characters in order to retain original label
that may contain HTML
// characters. This prevents having characters evaluated or
stripped via
// OutputPage::setPageTitle:
@@ -133,21 +132,21 @@
$this->msg(
'difference-title'
// This should be something like the following,
- // $labelLang->getDirMark() . $labelText .
$wgLang->getDirMark()
+ // $labelLang->getDirMark() . $titleText .
$wgLang->getDirMark()
// or should set the attribute of the h1 to
correct direction.
// Still note that the direction is "auto" so
guessing should
// give the right direction in most cases.
- )->rawParams( htmlspecialchars( $labelText ) )
+ )->rawParams( htmlspecialchars( $titleText ) )
);
}
/**
* @param OutputPage $outputPage
- * @param string $labelText
+ * @param string $titleText
*/
- private function setHTMLTitle( OutputPage $outputPage, $labelText ) {
+ private function setHTMLTitle( OutputPage $outputPage, $titleText ) {
// Prevent replacing {{...}} by using rawParams() instead of
params():
- $outputPage->setHTMLTitle( $this->msg( 'pagetitle'
)->rawParams( $labelText ) );
+ $outputPage->setHTMLTitle( $this->msg( 'pagetitle'
)->rawParams( $titleText ) );
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/179135
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic20c54407447e517e3fd7926060c0bc85013892a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits