jenkins-bot has submitted this change and it was merged.

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, 74 insertions(+), 76 deletions(-)

Approvals:
  Ori.livneh: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/specials/SpecialWatchlist.php 
b/includes/specials/SpecialWatchlist.php
index afdf981..9caa5a8 100644
--- a/includes/specials/SpecialWatchlist.php
+++ b/includes/specials/SpecialWatchlist.php
@@ -145,27 +145,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 ) {
@@ -179,7 +160,40 @@
                        return;
                }
 
+               if ( ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) && 
$request->getVal( 'reset' ) &&
+                       $request->wasPosted() )
+               {
+                       $user->clearAllNotifications();
+                       $output->redirect( $this->getPageTitle()->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 ) {
@@ -206,17 +220,6 @@
                        }
                } else {
                        $nameSpaceClause = '';
-               }
-
-               // Dump everything here
-               $nondefaults = $opts->getChangedValues();
-
-               if ( ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) && 
$request->getVal( 'reset' )
-                       && $request->wasPosted()
-               ) {
-                       $user->clearAllNotifications();
-                       $output->redirect( $this->getPageTitle()->getFullURL( 
$nondefaults ) );
-                       return;
                }
 
                # Possible where conditions
@@ -270,51 +273,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->getPageTitle()->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->getPageTitle()->getLocalURL(),
-                       'id' => 'mw-watchlist-form'
-               ) );
-               $form .= Xml::fieldset(
-                       $this->msg( 'watchlist-options' )->text(),
-                       false,
-                       array( 'id' => 'mw-watchlist-options' )
-               );
-
-               $form .= SpecialRecentChanges::makeLegend( $this->getContext() 
);
-
                $tables = array( 'recentchanges', 'watchlist' );
                $fields = RecentChange::selectFields();
                $join_conds = array(
@@ -360,6 +318,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
@@ -389,6 +348,45 @@
                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->getPageTitle()->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->getPageTitle()->getLocalURL(),
+                       'id' => 'mw-watchlist-form'
+               ) );
+               $form .= Xml::fieldset(
+                       $this->msg( 'watchlist-options' )->text(),
+                       false,
+                       array( 'id' => 'mw-watchlist-options' )
+               );
+
+               $form .= SpecialRecentChanges::makeLegend( $this->getContext() 
);
+
                # 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: merged
Gerrit-Change-Id: I6f525506b0fc4c009989ed7dff838c4e21ec4860
Gerrit-PatchSet: 10
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz DziewoƄski <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to