jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/379602 )

Change subject: WLFilters: Live update and View newest
......................................................................


WLFilters: Live update and View newest

Moved handling for 'from', 'days' and 'limit'
to base class (ChangesListSpecialPage)

I moved 'days' because its implementation
is related to 'from'.

I moved 'limit' because it was getting lonely
and it's identical in all cases.

Bug: T176348
Change-Id: If6280ad6fbad65909e1d0b2a48344e24d485aca2
---
M includes/specialpage/ChangesListSpecialPage.php
M includes/specials/SpecialRecentchanges.php
M includes/specials/SpecialWatchlist.php
M resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.ChangesListViewModel.js
4 files changed, 26 insertions(+), 78 deletions(-)

Approvals:
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/specialpage/ChangesListSpecialPage.php 
b/includes/specialpage/ChangesListSpecialPage.php
index d7519d3..6fd33a7 100644
--- a/includes/specialpage/ChangesListSpecialPage.php
+++ b/includes/specialpage/ChangesListSpecialPage.php
@@ -957,6 +957,11 @@
                $opts->add( 'urlversion', 1 );
                $opts->add( 'tagfilter', '' );
 
+               $opts->add( 'days', $this->getDefaultDays(), FormOptions::FLOAT 
);
+               $opts->add( 'limit', $this->getDefaultLimit(), FormOptions::INT 
);
+
+               $opts->add( 'from', '' );
+
                return $opts;
        }
 
@@ -1110,6 +1115,9 @@
                        $query = wfArrayToCgi( $this->convertParamsForLink( 
$opts->getChangedValues() ) );
                        $this->getOutput()->redirect( 
$this->getPageTitle()->getCanonicalURL( $query ) );
                }
+
+               $opts->validateIntBounds( 'limit', 0, 5000 );
+               $opts->validateBounds( 'days', 0, $this->getConfig()->get( 
'RCMaxAge' ) / ( 3600 * 24 ) );
        }
 
        /**
@@ -1249,6 +1257,19 @@
                        }
                        $conds[] = "rc_namespace $operator $value";
                }
+
+               // Calculate cutoff
+               $cutoff_unixtime = time() - $opts['days'] * 3600 * 24;
+               $cutoff = $dbr->timestamp( $cutoff_unixtime );
+
+               $fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
+               if ( $fromValid && $opts['from'] > wfTimestamp( TS_MW, $cutoff 
) ) {
+                       $cutoff = $dbr->timestamp( $opts['from'] );
+               } else {
+                       $opts->reset( 'from' );
+               }
+
+               $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
        }
 
        /**
diff --git a/includes/specials/SpecialRecentchanges.php 
b/includes/specials/SpecialRecentchanges.php
index 34a7714..522a0a6 100644
--- a/includes/specials/SpecialRecentchanges.php
+++ b/includes/specials/SpecialRecentchanges.php
@@ -164,10 +164,6 @@
                        true
                );
                parent::execute( $subpage );
-
-               if ( $this->isStructuredFilterUiEnabled() ) {
-                       $out->addJsConfigVars( 
'wgStructuredChangeFiltersLiveUpdateSupported', true );
-               }
        }
 
        /**
@@ -232,10 +228,6 @@
        public function getDefaultOptions() {
                $opts = parent::getDefaultOptions();
 
-               $opts->add( 'days', $this->getDefaultDays(), FormOptions::FLOAT 
);
-               $opts->add( 'limit', $this->getDefaultLimit() );
-               $opts->add( 'from', '' );
-
                $opts->add( 'categories', '' );
                $opts->add( 'categories_any', false );
 
@@ -285,36 +277,6 @@
                                $opts['tagfilter'] = $m[1];
                        }
                }
-       }
-
-       public function validateOptions( FormOptions $opts ) {
-               $opts->validateIntBounds( 'limit', 0, 5000 );
-               $opts->validateBounds( 'days', 0, $this->getConfig()->get( 
'RCMaxAge' ) / ( 3600 * 24 ) );
-               parent::validateOptions( $opts );
-       }
-
-       /**
-        * @inheritDoc
-        */
-       protected function buildQuery( &$tables, &$fields, &$conds,
-               &$query_options, &$join_conds, FormOptions $opts
-       ) {
-               $dbr = $this->getDB();
-               parent::buildQuery( $tables, $fields, $conds,
-                       $query_options, $join_conds, $opts );
-
-               // Calculate cutoff
-               $cutoff_unixtime = time() - $opts['days'] * 3600 * 24;
-               $cutoff = $dbr->timestamp( $cutoff_unixtime );
-
-               $fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
-               if ( $fromValid && $opts['from'] > wfTimestamp( TS_MW, $cutoff 
) ) {
-                       $cutoff = $dbr->timestamp( $opts['from'] );
-               } else {
-                       $opts->reset( 'from' );
-               }
-
-               $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
        }
 
        /**
diff --git a/includes/specials/SpecialWatchlist.php 
b/includes/specials/SpecialWatchlist.php
index 4f4570e..531184b 100644
--- a/includes/specials/SpecialWatchlist.php
+++ b/includes/specials/SpecialWatchlist.php
@@ -101,7 +101,6 @@
                if ( $this->isStructuredFilterUiEnabled() ) {
                        $output->addModuleStyles( [ 
'mediawiki.rcfilters.highlightCircles.seenunseen.styles' ] );
 
-                       $output->addJsConfigVars( 
'wgStructuredChangeFiltersLiveUpdateSupported', false );
                        $output->addJsConfigVars(
                                'wgStructuredChangeFiltersEditWatchlistUrl',
                                SpecialPage::getTitleFor( 'EditWatchlist' 
)->getLocalURL()
@@ -269,26 +268,6 @@
        }
 
        /**
-        * Get a FormOptions object containing the default options
-        *
-        * @return FormOptions
-        */
-       public function getDefaultOptions() {
-               $opts = parent::getDefaultOptions();
-
-               $opts->add( 'days', $this->getDefaultDays(), FormOptions::FLOAT 
);
-               $opts->add( 'limit', $this->getDefaultLimit(), FormOptions::INT 
);
-
-               return $opts;
-       }
-
-       public function validateOptions( FormOptions $opts ) {
-               $opts->validateBounds( 'days', 0, $this->maxDays );
-               $opts->validateIntBounds( 'limit', 0, 5000 );
-               parent::validateOptions( $opts );
-       }
-
-       /**
         * Get all custom filters
         *
         * @return array Map of filter URL param names to properties 
(msg/default)
@@ -358,23 +337,6 @@
                $opts->fetchValuesFromRequest( $request );
 
                return $opts;
-       }
-
-       /**
-        * @inheritDoc
-        */
-       protected function buildQuery( &$tables, &$fields, &$conds, 
&$query_options,
-               &$join_conds, FormOptions $opts
-       ) {
-               $dbr = $this->getDB();
-               parent::buildQuery( $tables, $fields, $conds, $query_options, 
$join_conds,
-                       $opts );
-
-               // Calculate cutoff
-               if ( $opts['days'] > 0 ) {
-                       $conds[] = 'rc_timestamp > ' .
-                               $dbr->addQuotes( $dbr->timestamp( time() - 
$opts['days'] * 3600 * 24 ) );
-               }
        }
 
        /**
@@ -654,7 +616,10 @@
                $timestamp = wfTimestampNow();
                $wlInfo = Html::rawElement(
                        'span',
-                       [ 'class' => 'wlinfo' ],
+                       [
+                               'class' => 'wlinfo',
+                               'data-params' => json_encode( [ 'from' => 
$timestamp ] ),
+                       ],
                        $this->msg( 'wlnote' )->numParams( $numRows, round( 
$days * 24 ) )->params(
                                $lang->userDate( $timestamp, $user ), 
$lang->userTime( $timestamp, $user )
                        )->parse()
diff --git 
a/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.ChangesListViewModel.js 
b/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.ChangesListViewModel.js
index 0155a58..debe0b9 100644
--- 
a/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.ChangesListViewModel.js
+++ 
b/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.ChangesListViewModel.js
@@ -110,7 +110,7 @@
         * @param {jQuery} $fieldset
         */
        mw.rcfilters.dm.ChangesListViewModel.prototype.extractNextFrom = 
function ( $fieldset ) {
-               var data = $fieldset.find( '.rclistfrom > a' ).data( 'params' );
+               var data = $fieldset.find( '.rclistfrom > a, .wlinfo' ).data( 
'params' );
                this.nextFrom = data ? data.from : null;
        };
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If6280ad6fbad65909e1d0b2a48344e24d485aca2
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Sbisson <sbis...@wikimedia.org>
Gerrit-Reviewer: Catrope <r...@wikimedia.org>
Gerrit-Reviewer: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com>
Gerrit-Reviewer: Jack Phoenix <j...@countervandalism.net>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to