jenkins-bot has submitted this change and it was merged.
Change subject: ChangesListSpecialPage: Implement execute()
......................................................................
ChangesListSpecialPage: Implement execute()
Merging common content from SpecialRecentChanges and SpecialWatchlist
plus some cleanup.
Change-Id: Ic4bbedf2015a9f20a6e63ec53a72df91f1e3a2fe
---
M includes/specialpage/ChangesListSpecialPage.php
M includes/specials/SpecialRecentchanges.php
M includes/specials/SpecialWatchlist.php
3 files changed, 99 insertions(+), 102 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/specialpage/ChangesListSpecialPage.php
b/includes/specialpage/ChangesListSpecialPage.php
index d5ec18c..1d17394 100644
--- a/includes/specialpage/ChangesListSpecialPage.php
+++ b/includes/specialpage/ChangesListSpecialPage.php
@@ -32,19 +32,63 @@
protected $customFilters;
/**
+ * The feed format to output as (either 'rss' or 'atom'), or null if no
+ * feed output was requested
+ *
+ * @var string $feedFormat
+ */
+ protected $feedFormat;
+
+ /**
* Main execution point
- * @todo This should totally do things
*
* @param string $subpage
*/
public function execute( $subpage ) {
$this->rcSubpage = $subpage;
- throw new MWException( "Not implemented" );
+ $this->feedFormat = $this->including() ? null :
$this->getRequest()->getVal( 'feed' );
+ if ( $this->feedFormat !== 'atom' && $this->feedFormat !==
'rss' ) {
+ $this->feedFormat = null;
+ }
+
+ $this->setHeaders();
+ $this->outputHeader();
+ $this->addModules();
+
+ $opts = $this->getOptions();
+ // Fetch results, prepare a batch link existence check query
+ $conds = $this->buildMainQueryConds( $opts );
+ $rows = $this->doMainQuery( $conds, $opts );
+ if ( $rows === false ) {
+ if ( !$this->including() ) {
+ $this->doHeader( $opts );
+ }
+
+ return;
+ }
+
+ if ( !$this->feedFormat ) {
+ $batch = new LinkBatch;
+ foreach ( $rows as $row ) {
+ $batch->add( NS_USER, $row->rc_user_text );
+ $batch->add( NS_USER_TALK, $row->rc_user_text );
+ $batch->add( $row->rc_namespace, $row->rc_title
);
+ }
+ $batch->execute();
+ }
+ if ( $this->feedFormat ) {
+ list( $changesFeed, $formatter ) =
$this->getFeedObject( $this->feedFormat );
+ /** @var ChangesFeed $changesFeed */
+ $changesFeed->execute( $formatter, $rows,
$this->checkLastModified( $this->feedFormat ), $opts );
+ } else {
+ $this->webOutput( $rows, $opts );
+ }
+
+ $rows->free();
}
/**
* Get the current FormOptions for this request
- * @todo Not called by anything, should be called by execute()
*
* @return FormOptions
*/
@@ -142,7 +186,6 @@
/**
* Return an array of conditions depending of options set in $opts
* @todo This should build some basic conditions here…
- * @todo Not called by anything, should be called by execute()
*
* @param FormOptions $opts
* @return array
@@ -152,7 +195,6 @@
/**
* Process the query
* @todo This should build some basic processing here…
- * @todo Not called by anything, should be called by execute()
*
* @param array $conds
* @param FormOptions $opts
@@ -163,9 +205,8 @@
/**
* Send output to the OutputPage object, only called if not used feeds
* @todo This should do most, if not all, of the outputting now done by
subclasses
- * @todo Not called by anything, should be called by execute()
*
- * @param array $rows Database rows
+ * @param ResultWrapper $rows Database rows
* @param FormOptions $opts
*/
abstract public function webOutput( $rows, $opts );
@@ -278,7 +319,6 @@
/**
* Add page-specific modules.
- * @todo Not called by anything, should be called by execute()
*/
protected function addModules() {
$out = $this->getOutput();
@@ -287,6 +327,30 @@
$out->addModules( 'mediawiki.special.changeslist.legend.js' );
}
+ /**
+ * Return an array with a ChangesFeed object and ChannelFeed object.
+ *
+ * This is intentionally not abstract not to require subclasses which
don't
+ * use feeds functionality to implement it.
+ *
+ * @param string $feedFormat Feed's format (either 'rss' or 'atom')
+ * @return array
+ */
+ public function getFeedObject( $feedFormat ) {
+ throw new MWException( "Not implemented" );
+ }
+
+ /**
+ * Get last-modified date, for client caching. Not implemented by
default
+ * (returns current time).
+ *
+ * @param string $feedFormat
+ * @return string|bool
+ */
+ public function checkLastModified( $feedFormat ) {
+ return wfTimestampNow();
+ }
+
protected function getGroupName() {
return 'changes';
}
diff --git a/includes/specials/SpecialRecentchanges.php
b/includes/specials/SpecialRecentchanges.php
index 4f89c00..d0e6171 100644
--- a/includes/specials/SpecialRecentchanges.php
+++ b/includes/specials/SpecialRecentchanges.php
@@ -27,13 +27,6 @@
* @ingroup SpecialPage
*/
class SpecialRecentChanges extends ChangesListSpecialPage {
- /**
- * The feed format to output as (either 'rss' or 'atom'), or null if no
- * feed output was requested
- *
- * @var string $feedFormat
- */
- protected $feedFormat;
public function __construct( $name = 'Recentchanges', $restriction = ''
) {
parent::__construct( $name, $restriction );
@@ -45,51 +38,15 @@
* @param string $subpage
*/
public function execute( $subpage ) {
- $this->rcSubpage = $subpage;
- $this->feedFormat = $this->including() ? null :
$this->getRequest()->getVal( 'feed' );
-
- # 10 seconds server-side caching max
+ // 10 seconds server-side caching max
$this->getOutput()->setSquidMaxage( 10 );
- # Check if the client has a cached version
+ // Check if the client has a cached version
$lastmod = $this->checkLastModified( $this->feedFormat );
if ( $lastmod === false ) {
return;
}
- $opts = $this->getOptions();
- $this->setHeaders();
- $this->outputHeader();
- $this->addModules();
-
- // Fetch results, prepare a batch link existence check query
- $conds = $this->buildMainQueryConds( $opts );
- $rows = $this->doMainQuery( $conds, $opts );
- if ( $rows === false ) {
- if ( !$this->including() ) {
- $this->doHeader( $opts );
- }
-
- return;
- }
-
- if ( !$this->feedFormat ) {
- $batch = new LinkBatch;
- foreach ( $rows as $row ) {
- $batch->add( NS_USER, $row->rc_user_text );
- $batch->add( NS_USER_TALK, $row->rc_user_text );
- $batch->add( $row->rc_namespace, $row->rc_title
);
- }
- $batch->execute();
- }
- if ( $this->feedFormat ) {
- list( $changesFeed, $formatter ) =
$this->getFeedObject( $this->feedFormat );
- /** @var ChangesFeed $changesFeed */
- $changesFeed->execute( $formatter, $rows, $lastmod,
$opts );
- } else {
- $this->webOutput( $rows, $opts );
- }
-
- $rows->free();
+ parent::execute( $subpage );
}
/**
@@ -593,7 +550,7 @@
}
/**
- * Return an array with a ChangesFeed object and ChannelFeed object
+ * Return an array with a ChangesFeed object and ChannelFeed object.
*
* @param string $feedFormat Feed's format (either 'rss' or 'atom')
* @return array
@@ -676,7 +633,7 @@
/**
* Filter $rows by categories set in $opts
*
- * @param array $rows Database rows
+ * @param ResultWrapper $rows Database rows
* @param FormOptions $opts
*/
function filterByCategories( &$rows, FormOptions $opts ) {
diff --git a/includes/specials/SpecialWatchlist.php
b/includes/specials/SpecialWatchlist.php
index f19d232..aef50c0 100644
--- a/includes/specials/SpecialWatchlist.php
+++ b/includes/specials/SpecialWatchlist.php
@@ -18,7 +18,14 @@
* http://www.gnu.org/copyleft/gpl.html
*
* @file
- * @ingroup SpecialPage Watchlist
+ * @ingroup SpecialPage
+ */
+
+/**
+ * A special page that lists last changes made to the wiki,
+ * limited to user-defined list of titles.
+ *
+ * @ingroup SpecialPage
*/
class SpecialWatchlist extends ChangesListSpecialPage {
/**
@@ -29,25 +36,20 @@
}
/**
- * Execute
- * @param $par Parameter passed to the page
+ * Main execution point
+ *
+ * @param string $subpage
*/
- function execute( $par ) {
+ function execute( $subpage ) {
global $wgRCShowWatchingUsers, $wgEnotifWatchlist,
$wgShowUpdatedMarker;
- $user = $this->getUser();
- $output = $this->getOutput();
-
- # Anons don't get a watchlist
+ // Anons don't get a watchlist
$this->requireLogin( 'watchlistanontext' );
- // Check permissions
- $this->checkPermissions();
-
+ $output = $this->getOutput();
$request = $this->getRequest();
- $opts = $this->getOptions();
- $mode = SpecialEditWatchlist::getMode( $request, $par );
+ $mode = SpecialEditWatchlist::getMode( $request, $subpage );
if ( $mode !== false ) {
if ( $mode === SpecialEditWatchlist::EDIT_RAW ) {
$title = SpecialPage::getTitleFor(
'EditWatchlist', 'raw' );
@@ -59,6 +61,11 @@
return;
}
+ $this->checkPermissions();
+
+ $user = $this->getUser();
+ $opts = $this->getOptions();
+
if ( ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) &&
$request->getVal( 'reset' ) &&
$request->wasPosted() )
{
@@ -67,38 +74,7 @@
return;
}
- $this->setHeaders();
- $this->outputHeader();
- $this->addModules();
-
- // Fetch results, prepare a batch link existence check query
- $conds = $this->buildMainQueryConds( $opts );
- $rows = $this->doMainQuery( $conds, $opts );
- if ( $rows === false ) {
- $this->doHeader( $opts );
-
- return;
- }
-
- $feedFormat = $this->getRequest()->getVal( 'feed' );
- if ( !$feedFormat ) {
- $batch = new LinkBatch;
- foreach ( $rows as $row ) {
- $batch->add( NS_USER, $row->rc_user_text );
- $batch->add( NS_USER_TALK, $row->rc_user_text );
- $batch->add( $row->rc_namespace, $row->rc_title
);
- }
- $batch->execute();
- }
- if ( $feedFormat ) {
- list( $changesFeed, $formatter ) =
$this->getFeedObject( $feedFormat );
- /** @var ChangesFeed $changesFeed */
- $changesFeed->execute( $formatter, $rows, $lastmod,
$opts );
- } else {
- $this->webOutput( $rows, $opts );
- }
-
- $rows->free();
+ parent::execute( $subpage );
}
/**
@@ -321,7 +297,7 @@
/**
* Send output to the OutputPage object, only called if not used feeds
*
- * @param array $rows Database rows
+ * @param ResultWrapper $rows Database rows
* @param FormOptions $opts
*/
public function webOutput( $rows, $opts ) {
--
To view, visit https://gerrit.wikimedia.org/r/103240
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic4bbedf2015a9f20a6e63ec53a72df91f1e3a2fe
Gerrit-PatchSet: 11
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits