Merge "rdbms: improve query logging logic in Database"
[lhc/web/wiklou.git] / includes / specialpage / QueryPage.php
index 144732c..700672f 100644 (file)
@@ -285,21 +285,6 @@ abstract class QueryPage extends SpecialPage {
                return [];
        }
 
-       /**
-        * Some special pages (for example SpecialListusers used to) might not return the
-        * current object formatted, but return the previous one instead.
-        * Setting this to return true will ensure formatResult() is called
-        * one more time to make sure that the very last result is formatted
-        * as well.
-        *
-        * @deprecated since 1.27
-        *
-        * @return bool
-        */
-       function tryLastResult() {
-               return false;
-       }
-
        /**
         * Clear the cache and save new results
         *
@@ -384,7 +369,7 @@ abstract class QueryPage extends SpecialPage {
 
        /**
         * Get a DB connection to be used for slow recache queries
-        * @return \Wikimedia\Rdbms\Database
+        * @return IDatabase
         */
        function getRecacheDB() {
                return wfGetDB( DB_REPLICA, [ $this->getName(), 'QueryPage::recache', 'vslow' ] );
@@ -578,7 +563,7 @@ abstract class QueryPage extends SpecialPage {
        /**
         * This is the actual workhorse. It does everything needed to make a
         * real, honest-to-gosh query page.
-        * @param string $par
+        * @param string|null $par
         */
        public function execute( $par ) {
                $user = $this->getUser();
@@ -658,8 +643,8 @@ abstract class QueryPage extends SpecialPage {
                                $miserMaxResults = $this->getConfig()->get( 'MiserMode' )
                                        && ( $this->offset + $this->limit >= $this->getMaxResults() );
                                $atEnd = ( $this->numRows <= $this->limit ) || $miserMaxResults;
-                               $paging = $this->getLanguage()->viewPrevNext( $this->getPageTitle( $par ), $this->offset,
-                                       $this->limit, $this->linkParameters(), $atEnd );
+                               $paging = $this->buildPrevNextNavigation( $this->offset,
+                                       $this->limit, $this->linkParameters(), $atEnd, $par );
                                $out->addHTML( '<p>' . $paging . '</p>' );
                        } else {
                                # No results to show, so don't bother with "showing X of Y" etc.
@@ -717,17 +702,6 @@ abstract class QueryPage extends SpecialPage {
                                }
                        }
 
-                       # Flush the final result
-                       if ( $this->tryLastResult() ) {
-                               $row = null;
-                               $line = $this->formatResult( $skin, $row );
-                               if ( $line ) {
-                                       $html[] = $this->listoutput
-                                               ? $line
-                                               : "<li>{$line}</li>\n";
-                               }
-                       }
-
                        if ( !$this->listoutput ) {
                                $html[] = $this->closeList();
                        }
@@ -763,98 +737,6 @@ abstract class QueryPage extends SpecialPage {
        function preprocessResults( $db, $res ) {
        }
 
-       /**
-        * Similar to above, but packaging in a syndicated feed instead of a web page
-        * @param string $class
-        * @param int $limit
-        * @return bool
-        */
-       function doFeed( $class = '', $limit = 50 ) {
-               if ( !$this->getConfig()->get( 'Feed' ) ) {
-                       $this->getOutput()->addWikiMsg( 'feed-unavailable' );
-                       return false;
-               }
-
-               $limit = min( $limit, $this->getConfig()->get( 'FeedLimit' ) );
-
-               $feedClasses = $this->getConfig()->get( 'FeedClasses' );
-               if ( isset( $feedClasses[$class] ) ) {
-                       /** @var RSSFeed|AtomFeed $feed */
-                       $feed = new $feedClasses[$class](
-                               $this->feedTitle(),
-                               $this->feedDesc(),
-                               $this->feedUrl() );
-                       $feed->outHeader();
-
-                       $res = $this->reallyDoQuery( $limit, 0 );
-                       foreach ( $res as $obj ) {
-                               $item = $this->feedResult( $obj );
-                               if ( $item ) {
-                                       $feed->outItem( $item );
-                               }
-                       }
-
-                       $feed->outFooter();
-                       return true;
-               } else {
-                       return false;
-               }
-       }
-
-       /**
-        * Override for custom handling. If the titles/links are ok, just do
-        * feedItemDesc()
-        * @param object $row
-        * @return FeedItem|null
-        */
-       function feedResult( $row ) {
-               if ( !isset( $row->title ) ) {
-                       return null;
-               }
-               $title = Title::makeTitle( intval( $row->namespace ), $row->title );
-               if ( $title ) {
-                       $date = $row->timestamp ?? '';
-                       $comments = '';
-                       if ( $title ) {
-                               $talkpage = $title->getTalkPage();
-                               $comments = $talkpage->getFullURL();
-                       }
-
-                       return new FeedItem(
-                               $title->getPrefixedText(),
-                               $this->feedItemDesc( $row ),
-                               $title->getFullURL(),
-                               $date,
-                               $this->feedItemAuthor( $row ),
-                               $comments );
-               } else {
-                       return null;
-               }
-       }
-
-       function feedItemDesc( $row ) {
-               return isset( $row->comment ) ? htmlspecialchars( $row->comment ) : '';
-       }
-
-       function feedItemAuthor( $row ) {
-               return $row->user_text ?? '';
-       }
-
-       function feedTitle() {
-               $desc = $this->getDescription();
-               $code = $this->getConfig()->get( 'LanguageCode' );
-               $sitename = $this->getConfig()->get( 'Sitename' );
-               return "$sitename - $desc [$code]";
-       }
-
-       function feedDesc() {
-               return $this->msg( 'tagline' )->text();
-       }
-
-       function feedUrl() {
-               return $this->getPageTitle()->getFullURL();
-       }
-
        /**
         * Creates a new LinkBatch object, adds all pages from the passed ResultWrapper (MUST include
         * title and optional the namespace field) and executes the batch. This operation will pre-cache