Bartosz Dziewoński has uploaded a new change for review.

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


Change subject: SpecialWatchlist: Reorder some stuff in #execute
......................................................................

SpecialWatchlist: Reorder some stuff in #execute

In order to reduce the interconnectedness between parameter parsing,
database queries and building output, and to make later changes where
I'll start removing some of this code easier to understand.

Change-Id: I6f525506b0fc4c009989ed7dff838c4e21ec4860
---
M includes/specials/SpecialWatchlist.php
1 file changed, 72 insertions(+), 74 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/27/94627/1

diff --git a/includes/specials/SpecialWatchlist.php 
b/includes/specials/SpecialWatchlist.php
index 802aeed..05f7390 100644
--- a/includes/specials/SpecialWatchlist.php
+++ b/includes/specials/SpecialWatchlist.php
@@ -154,27 +154,8 @@
                // Check permissions
                $this->checkPermissions();
 
-               // Add feed links
-               $wlToken = $user->getTokenFromOption( 'watchlisttoken' );
-               if ( $wlToken ) {
-                       $this->addFeedLinks( array(
-                               'action' => 'feedwatchlist',
-                               'allrev' => 1,
-                               'wlowner' => $user->getName(),
-                               'wltoken' => $wlToken,
-                       ) );
-               }
-
-               $opts = $this->getOptions();
-               $this->setHeaders();
-               $this->outputHeader();
-
-               $output->addSubtitle(
-                       $this->msg( 'watchlistfor2', $user->getName() )
-                               ->rawParams( SpecialEditWatchlist::buildTools( 
null ) )
-               );
-
                $request = $this->getRequest();
+               $opts = $this->getOptions();
 
                $mode = SpecialEditWatchlist::getMode( $request, $par );
                if ( $mode !== false ) {
@@ -188,7 +169,40 @@
                        return;
                }
 
+               if ( ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) && 
$request->getVal( 'reset' ) &&
+                       $request->wasPosted() )
+               {
+                       $user->clearAllNotifications();
+                       $output->redirect( $this->getTitle()->getFullURL( 
$opts->getChangedValues() ) );
+                       return;
+               }
+
+               $this->setHeaders();
+               $this->outputHeader();
+
+               // Add feed links
+               $wlToken = $user->getTokenFromOption( 'watchlisttoken' );
+               if ( $wlToken ) {
+                       $this->addFeedLinks( array(
+                               'action' => 'feedwatchlist',
+                               'allrev' => 1,
+                               'wlowner' => $user->getName(),
+                               'wltoken' => $wlToken,
+                       ) );
+               }
+
+               $output->addSubtitle(
+                       $this->msg( 'watchlistfor2', $user->getName() )
+                               ->rawParams( SpecialEditWatchlist::buildTools( 
null ) )
+               );
+
                $dbr = wfGetDB( DB_SLAVE, 'watchlist' );
+
+               # Show a message about slave lag, if applicable
+               $lag = wfGetLB()->safeGetLag( $dbr );
+               if ( $lag > 0 ) {
+                       $output->showLagWarning( $lag );
+               }
 
                $nitems = $this->countItems( $dbr );
                if ( $nitems == 0 ) {
@@ -215,17 +229,6 @@
                        }
                } else {
                        $nameSpaceClause = '';
-               }
-
-               // Dump everything here
-               $nondefaults = $opts->getChangedValues();
-
-               if ( ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) && 
$request->getVal( 'reset' ) &&
-                       $request->wasPosted() )
-               {
-                       $user->clearAllNotifications();
-                       $output->redirect( $this->getTitle()->getFullURL( 
$nondefaults ) );
-                       return;
                }
 
                # Possible where conditions
@@ -279,49 +282,6 @@
                        $usePage = true;
                }
 
-               # Show a message about slave lag, if applicable
-               $lag = wfGetLB()->safeGetLag( $dbr );
-               if ( $lag > 0 ) {
-                       $output->showLagWarning( $lag );
-               }
-
-               # Create output
-               $form = '';
-
-               # Show watchlist header
-               $form .= "<p>";
-               $form .= $this->msg( 'watchlist-details' )->numParams( $nitems 
)->parse() . "\n";
-               if ( $wgEnotifWatchlist && $user->getOption( 
'enotifwatchlistpages' ) ) {
-                       $form .= $this->msg( 'wlheader-enotif' )->parse() . 
"\n";
-               }
-               if ( $wgShowUpdatedMarker ) {
-                       $form .= $this->msg( 'wlheader-showupdated' )->parse() 
. "\n";
-               }
-               $form .= "</p>";
-
-               if ( $wgShowUpdatedMarker ) {
-                       $form .= Xml::openElement( 'form', array( 'method' => 
'post',
-                               'action' => $this->getTitle()->getLocalURL(),
-                               'id' => 'mw-watchlist-resetbutton' ) ) . "\n" .
-                       Xml::submitButton( $this->msg( 'enotif_reset' 
)->text(), array( 'name' => 'dummy' ) ) . "\n" .
-                       Html::hidden( 'reset', 'all' ) . "\n";
-                       foreach ( $nondefaults as $key => $value ) {
-                               $form .= Html::hidden( $key, $value ) . "\n";
-                       }
-                       $form .= Xml::closeElement( 'form' ) . "\n";
-               }
-
-               $form .= Xml::openElement( 'form', array(
-                       'method' => 'post',
-                       'action' => $this->getTitle()->getLocalURL(),
-                       'id' => 'mw-watchlist-form'
-               ) );
-               $form .= Xml::fieldset(
-                       $this->msg( 'watchlist-options' )->text(),
-                       false,
-                       array( 'id' => 'mw-watchlist-options' )
-               );
-
                $tables = array( 'recentchanges', 'watchlist' );
                $fields = RecentChange::selectFields();
                $join_conds = array(
@@ -367,6 +327,7 @@
                                $lang->userDate( $timestamp, $user ), 
$lang->userTime( $timestamp, $user ) )->parse() . "<br />\n";
                }
 
+               $nondefaults = $opts->getChangedValues();
                $cutofflinks = $this->cutoffLinks( $opts['days'], $nondefaults 
) . "<br />\n";
 
                # Spit out some control panel links
@@ -396,6 +357,43 @@
                unset( $hiddenFields['invert'] );
                unset( $hiddenFields['associated'] );
 
+               # Create output
+               $form = '';
+
+               # Show watchlist header
+               $form .= "<p>";
+               $form .= $this->msg( 'watchlist-details' )->numParams( $nitems 
)->parse() . "\n";
+               if ( $wgEnotifWatchlist && $user->getOption( 
'enotifwatchlistpages' ) ) {
+                       $form .= $this->msg( 'wlheader-enotif' )->parse() . 
"\n";
+               }
+               if ( $wgShowUpdatedMarker ) {
+                       $form .= $this->msg( 'wlheader-showupdated' )->parse() 
. "\n";
+               }
+               $form .= "</p>";
+
+               if ( $wgShowUpdatedMarker ) {
+                       $form .= Xml::openElement( 'form', array( 'method' => 
'post',
+                               'action' => $this->getTitle()->getLocalURL(),
+                               'id' => 'mw-watchlist-resetbutton' ) ) . "\n" .
+                       Xml::submitButton( $this->msg( 'enotif_reset' 
)->text(), array( 'name' => 'dummy' ) ) . "\n" .
+                       Html::hidden( 'reset', 'all' ) . "\n";
+                       foreach ( $nondefaults as $key => $value ) {
+                               $form .= Html::hidden( $key, $value ) . "\n";
+                       }
+                       $form .= Xml::closeElement( 'form' ) . "\n";
+               }
+
+               $form .= Xml::openElement( 'form', array(
+                       'method' => 'post',
+                       'action' => $this->getTitle()->getLocalURL(),
+                       'id' => 'mw-watchlist-form'
+               ) );
+               $form .= Xml::fieldset(
+                       $this->msg( 'watchlist-options' )->text(),
+                       false,
+                       array( 'id' => 'mw-watchlist-options' )
+               );
+
                # Namespace filter and put the whole form together.
                $form .= $wlInfo;
                $form .= $cutofflinks;

-- 
To view, visit https://gerrit.wikimedia.org/r/94627
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6f525506b0fc4c009989ed7dff838c4e21ec4860
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to