Jeroen De Dauw has submitted this change and it was merged.
Change subject: SpecialWikibaseQueryPage::formatRow is no longer abstract
......................................................................
SpecialWikibaseQueryPage::formatRow is no longer abstract
Moved the most common implementation of it into the base class since it seems
like the natural
formatting in the usual cases which can easily be predicted since we are always
dealing with
Entities (or rather entity IDs) as results to be displayed.
Also cleaned up several redundant doxygen comments, simply use @see rather than
having copies
of whole member signatures when overwriting them in subclasses.
Change-Id: I69c0b503a13efe51a906786bb1f99f6b076f0554
---
M client/includes/specials/SpecialUnconnectedPages.php
M lib/includes/specials/SpecialWikibasePage.php
M lib/includes/specials/SpecialWikibaseQueryPage.php
M repo/includes/specials/SpecialEntitiesWithoutPage.php
M repo/includes/specials/SpecialItemByTitle.php
M repo/includes/specials/SpecialItemDisambiguation.php
M repo/includes/specials/SpecialItemResolver.php
M repo/includes/specials/SpecialItemsWithoutSitelinks.php
8 files changed, 23 insertions(+), 105 deletions(-)
Approvals:
Jeroen De Dauw: Looks good to me, approved
jenkins-bot: Verified
diff --git a/client/includes/specials/SpecialUnconnectedPages.php
b/client/includes/specials/SpecialUnconnectedPages.php
index 10a0461..a09cacf 100644
--- a/client/includes/specials/SpecialUnconnectedPages.php
+++ b/client/includes/specials/SpecialUnconnectedPages.php
@@ -75,9 +75,6 @@
* @see SpecialWikibasePage::execute
*
* @since 0.4
- *
- * @param string $subPage
- * @return boolean
*/
public function execute( $subPage ) {
if ( !parent::execute( $subPage ) ) {
@@ -216,11 +213,6 @@
* @see SpecialWikibaseQueryPage::getResult
*
* @since 0.4
- *
- * @param integer $offset Start to include at number of entries from
the start title
- * @param integer $limit Stop at number of entries after start of
inclusion
- *
- * @return Array[]
*/
public function getResult( $offset = 0, $limit = 0 ) {
@@ -275,10 +267,6 @@
* @see SpecialWikibaseQueryPage::formatRow
*
* @since 0.4
- *
- * @param $entry The entry is for this call a row from the select in
getResult
- *
- * @return string|null
*/
protected function formatRow( $entry ) {
try {
@@ -297,8 +285,6 @@
* @see SpecialWikibaseQueryPage::getTitleForNavigation
*
* @since 0.4
- *
- * @return Title
*/
protected function getTitleForNavigation() {
return $this->getTitle( $this->startPage );
diff --git a/lib/includes/specials/SpecialWikibasePage.php
b/lib/includes/specials/SpecialWikibasePage.php
index f203f7e..54db829 100644
--- a/lib/includes/specials/SpecialWikibasePage.php
+++ b/lib/includes/specials/SpecialWikibasePage.php
@@ -70,14 +70,13 @@
* @see SpecialPage::getDescription
*
* @since 0.1
- * @return String
*/
public function getDescription() {
return $this->msg( 'special-' . strtolower( $this->getName() )
)->text();
}
/**
- * Sets headers - this should be called from the execute() method of
all derived classes!
+ * @see SpecialPage::setHeaders
*
* @since 0.1
*/
@@ -88,13 +87,9 @@
}
/**
- * Main method.
+ * @see SpecialPage::execute
*
* @since 0.1
- *
- * @param string|null $subPage
- *
- * @return boolean
*/
public function execute( $subPage ) {
$subPage = is_null( $subPage ) ? '' : $subPage;
diff --git a/lib/includes/specials/SpecialWikibaseQueryPage.php
b/lib/includes/specials/SpecialWikibaseQueryPage.php
index ec1a2fa..0e3953c 100644
--- a/lib/includes/specials/SpecialWikibaseQueryPage.php
+++ b/lib/includes/specials/SpecialWikibaseQueryPage.php
@@ -62,23 +62,31 @@
* Formats a row for display.
* If the function returns false, the line output will be skipped.
*
- * @since 0.3
+ * @since 0.4 (as abstract function with same interface in 0.3)
*
* @param $entry
*
- * @return string|null
+ * @return string|false
*/
- protected abstract function formatRow( $entry );
+ protected function formatRow( $entry ) {
+ try {
+ $title =
\Wikibase\EntityContentFactory::singleton()->getTitleForId( $entry );
+ return Linker::linkKnown( $title );
+ } catch ( MWException $e ) {
+ wfWarn( "Error formatting result row: " .
$e->getMessage() );
+ return false;
+ }
+ }
/**
* Return the result of the query
*
* @since 0.3
*
- * @param integer $offset
- * @param integer $limit
+ * @param integer $offset Start to include at number of entries from
the start title
+ * @param integer $limit Stop at number of entries after start of
inclusion
*
- * @return array
+ * @return Array[]
*/
protected abstract function getResult( $offset = 0, $limit = 0 );
diff --git a/repo/includes/specials/SpecialEntitiesWithoutPage.php
b/repo/includes/specials/SpecialEntitiesWithoutPage.php
index bcdc4b4..75f70d1 100644
--- a/repo/includes/specials/SpecialEntitiesWithoutPage.php
+++ b/repo/includes/specials/SpecialEntitiesWithoutPage.php
@@ -60,10 +60,6 @@
* @see SpecialWikibasePage::execute
*
* @since 0.4
- *
- * @param string $subPage
- *
- * @return boolean
*/
public function execute( $subPage ) {
if ( !parent::execute( $subPage ) ) {
@@ -206,33 +202,9 @@
}
/**
- * @see SpecialWikibaseQueryPage::formatRow
- *
- * @since 0.3
- *
- * @param $entry The entry is for this call an EntityId
- *
- * @return string|null
- */
- protected function formatRow( $entry ) {
- try {
- $title =
\Wikibase\EntityContentFactory::singleton()->getTitleForId( $entry );
- return Linker::linkKnown( $title );
- } catch ( MWException $e ) {
- wfWarn( "Error formatting result row: " .
$e->getMessage() );
- return false;
- }
- }
-
- /**
* @see SpecialWikibaseQueryPage::getResult
*
* @since 0.4
- *
- * @param integer $offset
- * @param integer $limit
- *
- * @return EntityId[]
*/
protected function getResult( $offset = 0, $limit = 0 ) {
$entityPerPage = \Wikibase\StoreFactory::getStore( 'sqlstore'
)->newEntityPerPage();
@@ -244,8 +216,6 @@
* @see SpecialWikibaseQueryPage::getTitleForNavigation
*
* @since 0.4
- *
- * @return Title
*/
protected function getTitleForNavigation() {
return $this->getTitle( $this->language . '/' . $this->type );
@@ -255,8 +225,6 @@
* Get the term type (member of Term::TYPE_ enum)
*
* @since 0.4
- *
- * @return string
*/
protected abstract function getTermType();
@@ -264,8 +232,6 @@
* Get the legend in HTML format
*
* @since 0.4
- *
- * @return string
*/
protected abstract function getLegend();
diff --git a/repo/includes/specials/SpecialItemByTitle.php
b/repo/includes/specials/SpecialItemByTitle.php
index ba3664a..3d3d413 100644
--- a/repo/includes/specials/SpecialItemByTitle.php
+++ b/repo/includes/specials/SpecialItemByTitle.php
@@ -42,13 +42,9 @@
}
/**
- * Main method.
+ * @see SpecialItemResolver::execute
*
* @since 0.1
- *
- * @param string|null $subPage
- *
- * @return boolean
*/
public function execute( $subPage ) {
parent::execute( $subPage );
diff --git a/repo/includes/specials/SpecialItemDisambiguation.php
b/repo/includes/specials/SpecialItemDisambiguation.php
index 9e126d2..234aaf0 100644
--- a/repo/includes/specials/SpecialItemDisambiguation.php
+++ b/repo/includes/specials/SpecialItemDisambiguation.php
@@ -44,13 +44,9 @@
}
/**
- * Main method.
+ * @see SpecialItemResolver::execute
*
* @since 0.1
- *
- * @param string|null $subPage
- *
- * @return boolean if the page call was successful
*/
public function execute( $subPage ) {
if ( !parent::execute( $subPage ) ) {
diff --git a/repo/includes/specials/SpecialItemResolver.php
b/repo/includes/specials/SpecialItemResolver.php
index 6ebf92f..08ed99a 100644
--- a/repo/includes/specials/SpecialItemResolver.php
+++ b/repo/includes/specials/SpecialItemResolver.php
@@ -38,17 +38,17 @@
* @since 0.1
*
* @param string $name
+ * @param string $restriction
+ * @param boolean $listed
*/
public function __construct( $name = '', $restriction = '', $listed =
true ) {
parent::__construct( $name, $restriction, $listed );
}
/**
- * The subpage, ie the part after Special:PageName/
- * Empty string if none is provided.
+ * @see SpecialWikibasePagePage::$subPage
*
* @since 0.1
- * @var string
*/
public $subPage;
@@ -56,14 +56,13 @@
* @see SpecialPage::getDescription
*
* @since 0.1
- * @return String
*/
public function getDescription() {
return $this->msg( 'special-' . strtolower( $this->getName() )
)->text();
}
/**
- * Sets headers - this should be called from the execute() method of
all derived classes!
+ * @see SpecialPage::setHeaders
*
* @since 0.1
*/
@@ -74,13 +73,9 @@
}
/**
- * Main method.
+ * @see SpecialPage::execute
*
* @since 0.1
- *
- * @param string|null $subPage
- *
- * @return boolean
*/
public function execute( $subPage ) {
$subPage = is_null( $subPage ) ? '' : $subPage;
diff --git a/repo/includes/specials/SpecialItemsWithoutSitelinks.php
b/repo/includes/specials/SpecialItemsWithoutSitelinks.php
index 97f0c13..c0139e9 100644
--- a/repo/includes/specials/SpecialItemsWithoutSitelinks.php
+++ b/repo/includes/specials/SpecialItemsWithoutSitelinks.php
@@ -51,33 +51,9 @@
}
/**
- * @see SpecialWikibaseQueryPage::formatRow
- *
- * @since 0.4
- *
- * @param $entry The entry is for this call an EntityId
- *
- * @return string|null
- */
- protected function formatRow( $entry ) {
- try {
- $title =
\Wikibase\EntityContentFactory::singleton()->getTitleForId( $entry );
- return Linker::linkKnown( $title );
- } catch ( MWException $e ) {
- wfWarn( "Error formatting result row: " .
$e->getMessage() );
- return false;
- }
- }
-
- /**
* @see SpecialWikibaseQueryPage::getResult
*
* @since 0.4
- *
- * @param integer $offset
- * @param integer $limit
- *
- * @return EntityId[]
*/
protected function getResult( $offset = 0, $limit = 0 ) {
$entityPerPage = \Wikibase\StoreFactory::getStore( 'sqlstore'
)->newEntityPerPage();
--
To view, visit https://gerrit.wikimedia.org/r/79345
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I69c0b503a13efe51a906786bb1f99f6b076f0554
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Werner <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Henning Snater <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: Tpt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits