Mattflaschen has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/378687 )

Change subject: WIP: RCFilters: Display specific error if query times out.
......................................................................

WIP: RCFilters: Display specific error if query times out.

The backend works but the frontend needs to be updated.

Bug: T175776
Change-Id: If4d880e9e6a56989895956798fc6918a43841065
---
M includes/specialpage/ChangesListSpecialPage.php
M languages/i18n/en.json
M languages/i18n/qqq.json
M resources/src/mediawiki.rcfilters/mw.rcfilters.init.js
4 files changed, 75 insertions(+), 38 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/87/378687/1

diff --git a/includes/specialpage/ChangesListSpecialPage.php 
b/includes/specialpage/ChangesListSpecialPage.php
index 0762bf7..587d356 100644
--- a/includes/specialpage/ChangesListSpecialPage.php
+++ b/includes/specialpage/ChangesListSpecialPage.php
@@ -21,6 +21,7 @@
  * @ingroup SpecialPage
  */
 use MediaWiki\Logger\LoggerFactory;
+use Wikimedia\Rdbms\DBQueryTimeoutError;
 use Wikimedia\Rdbms\ResultWrapper;
 use Wikimedia\Rdbms\FakeResultWrapper;
 use Wikimedia\Rdbms\IDatabase;
@@ -519,45 +520,56 @@
        public function execute( $subpage ) {
                $this->rcSubpage = $subpage;
 
-               $rows = $this->getRows();
                $opts = $this->getOptions();
-               if ( $rows === false ) {
-                       $rows = new FakeResultWrapper( [] );
-               }
+               try {
+                       $rows = $this->getRows();
+                       if ( $rows === false ) {
+                               $rows = new FakeResultWrapper( [] );
+                       }
 
-               // Used by Structured UI app to get results without MW chrome
-               if ( $this->getRequest()->getVal( 'action' ) === 'render' ) {
-                       $this->getOutput()->setArticleBodyOnly( true );
-               }
+                       // Used by Structured UI app to get results without MW 
chrome
+                       if ( $this->getRequest()->getVal( 'action' ) === 
'render' ) {
+                               $this->getOutput()->setArticleBodyOnly( true );
+                       }
 
-               // Used by "live update" and "view newest" to check
-               // if there's new changes with minimal data transfer
-               if ( $this->getRequest()->getBool( 'peek' ) ) {
-                       $code = $rows->numRows() > 0 ? 200 : 304;
-                       $this->getOutput()->setStatusCode( $code );
-                       return;
-               }
+                       // Used by "live update" and "view newest" to check
+                       // if there's new changes with minimal data transfer
+                       if ( $this->getRequest()->getBool( 'peek' ) ) {
+                               $code = $rows->numRows() > 0 ? 200 : 304;
+                               $this->getOutput()->setStatusCode( $code );
+                               return;
+                       }
 
-               $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 );
-                       if ( $row->rc_source === RecentChange::SRC_LOG ) {
-                               $formatter = LogFormatter::newFromRow( $row );
-                               foreach ( $formatter->getPreloadTitles() as 
$title ) {
-                                       $batch->addObj( $title );
+                       $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 
);
+                               if ( $row->rc_source === RecentChange::SRC_LOG 
) {
+                                       $formatter = LogFormatter::newFromRow( 
$row );
+                                       foreach ( 
$formatter->getPreloadTitles() as $title ) {
+                                               $batch->addObj( $title );
+                                       }
                                }
                        }
+                       $batch->execute();
+
+                       $this->setHeaders();
+                       $this->outputHeader();
+                       $this->addModules();
+                       $this->webOutput( $rows, $opts );
+
+                       $rows->free();
+               } catch ( DBQueryTimeoutError $timeoutException ) {
+                       MWExceptionHandler::logException( $timeoutException );
+
+                       $this->setHeaders();
+                       $this->outputHeader();
+                       $this->addModules();
+
+                       $this->webOutputHeader( 0, $opts );
+                       $this->outputTimeout();
                }
-               $batch->execute();
-
-               $this->setHeaders();
-               $this->outputHeader();
-               $this->addModules();
-               $this->webOutput( $rows, $opts );
-
-               $rows->free();
 
                if ( $this->getConfig()->get( 'EnableWANCacheReaper' ) ) {
                        // Clean up any bad page entries for titles showing up 
in RC
@@ -682,6 +694,17 @@
                $this->getOutput()->addHTML(
                        '<div class="mw-changeslist-empty">' .
                        $this->msg( 'recentchanges-noresult' )->parse() .
+                       '</div>'
+               );
+       }
+
+       /**
+        * Add the "timeout" message to the output
+        */
+       protected function outputTimeout() {
+               $this->getOutput()->addHTML(
+                       '<div class="mw-changeslist-timeout">' .
+                       $this->msg( 'recentchanges-timeout' )->parse() .
                        '</div>'
                );
        }
@@ -1283,16 +1306,26 @@
        }
 
        /**
+        * Send header output to the OutputPage object, only called if not 
using feeds
+        *
+        * @param int $rowCount Number of database rows
+        * @param FormOptions $opts
+        */
+       private function webOutputHeader( $rowCount, $opts ) {
+               if ( !$this->including() ) {
+                       $this->outputFeedLinks();
+                       $this->doHeader( $opts, $rowCount );
+               }
+       }
+
+       /**
         * Send output to the OutputPage object, only called if not used feeds
         *
         * @param ResultWrapper $rows Database rows
         * @param FormOptions $opts
         */
        public function webOutput( $rows, $opts ) {
-               if ( !$this->including() ) {
-                       $this->outputFeedLinks();
-                       $this->doHeader( $opts, $rows->numRows() );
-               }
+               $this->webOutputHeader( $rows->numRows(), $opts );
 
                $this->outputChangesList( $rows, $opts );
        }
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index 5dd8345..b5ddfcb 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -1338,6 +1338,7 @@
        "recentchanges-summary": "Track the most recent changes to the wiki on 
this page.",
        "recentchangestext": "-",
        "recentchanges-noresult": "No changes during the given period match 
these criteria.",
+       "recentchanges-timeout": "This query took too long, so it could not be 
completed.",
        "recentchanges-feed-description": "Track the most recent changes to the 
wiki in this feed.",
        "recentchanges-label-newpage": "This edit created a new page",
        "recentchanges-label-minor": "This is a minor edit",
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index 9d2e77d..5e5c1e7 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -1529,6 +1529,7 @@
        "recentchanges-summary": "Summary of [[Special:RecentChanges]].",
        "recentchangestext": "Text in [[Special:RecentChanges]]",
        "recentchanges-noresult": "Used in [[Special:RecentChanges]], 
[[Special:RecentChangesLinked]], and [[Special:Watchlist]] when there are no 
changes to be shown.",
+       "recentchanges-noresult": "Used in [[Special:RecentChanges]], 
[[Special:RecentChangesLinked]], and [[Special:Watchlist]] when a query times 
out.",
        "recentchanges-feed-description": "Used in feed of RecentChanges. See 
example [{{canonicalurl:Special:RecentChanges|feed=atom}} feed].",
        "recentchanges-label-newpage": "# Used as tooltip for 
{{msg-mw|Newpageletter}}.\n# Also used as legend. Preceded by 
{{msg-mw|Newpageletter}} and followed by 
{{msg-mw|Recentchanges-legend-newpage}}.",
        "recentchanges-label-minor": "# Used as tooltip for 
{{msg-mw|Minoreditletter}}\n# Also used as legend. Preceded by 
{{msg-mw|Minoreditletter}}",
diff --git a/resources/src/mediawiki.rcfilters/mw.rcfilters.init.js 
b/resources/src/mediawiki.rcfilters/mw.rcfilters.init.js
index 67edb4f..61dbb83 100644
--- a/resources/src/mediawiki.rcfilters/mw.rcfilters.init.js
+++ b/resources/src/mediawiki.rcfilters/mw.rcfilters.init.js
@@ -31,13 +31,15 @@
                                ),
                                currentPage = mw.config.get( 
'wgCanonicalNamespace' ) +
                                        ':' +
-                                       mw.config.get( 
'wgCanonicalSpecialPageName' );
+                                       mw.config.get( 
'wgCanonicalSpecialPageName' ),
+                               $changesListRoot;
 
                        // TODO: The changesListWrapperWidget should be able to 
initialize
                        // after the model is ready.
+                       $changesListRoot = $( '.mw-changeslist, 
.mw-changeslist-empty, .mw-changeslist-timeout' );
                        // eslint-disable-next-line no-new
                        new mw.rcfilters.ui.ChangesListWrapperWidget(
-                               filtersModel, changesListModel, controller, $( 
'.mw-changeslist, .mw-changeslist-empty' ) );
+                               filtersModel, changesListModel, controller, 
$changesListRoot );
 
                        controller.initialize(
                                mw.config.get( 'wgStructuredChangeFilters' ),

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If4d880e9e6a56989895956798fc6918a43841065
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Mattflaschen <mflasc...@wikimedia.org>

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

Reply via email to