Move IDatabase/IMaintainableDatabase to Rdbms namespace
[lhc/web/wiklou.git] / includes / specialpage / WantedQueryPage.php
index 39e3649..d788f2b 100644 (file)
@@ -21,6 +21,9 @@
  * @ingroup SpecialPage
  */
 
+use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IDatabase;
+
 /**
  * Class definition for a wanted query page like
  * WantedPages, WantedTemplates, etc
@@ -64,14 +67,15 @@ abstract class WantedQueryPage extends QueryPage {
         * @return string
         */
        public function formatResult( $skin, $result ) {
+               $linkRenderer = $this->getLinkRenderer();
                $title = Title::makeTitleSafe( $result->namespace, $result->title );
                if ( $title instanceof Title ) {
                        if ( $this->isCached() || $this->forceExistenceCheck() ) {
                                $pageLink = $this->existenceCheck( $title )
-                                       ? '<del>' . Linker::link( $title ) . '</del>'
-                                       : Linker::link( $title );
+                                       ? '<del>' . $linkRenderer->makeLink( $title ) . '</del>'
+                                       : $linkRenderer->makeLink( $title );
                        } else {
-                               $pageLink = Linker::link(
+                               $pageLink = $linkRenderer->makeLink(
                                        $title,
                                        null,
                                        [],
@@ -116,4 +120,37 @@ abstract class WantedQueryPage extends QueryPage {
                $label = $this->msg( 'nlinks' )->numParams( $result->value )->escaped();
                return Linker::link( $wlh, $label );
        }
+
+       /**
+        * Order by title for pages with the same number of links to them
+        *
+        * @return array
+        * @since 1.29
+        */
+       function getOrderFields() {
+               return [ 'value DESC', 'namespace', 'title' ];
+       }
+
+       /**
+        * Do not order descending for all order fields.  We will use DESC only on one field, see
+        * getOrderFields above. This overwrites sortDescending from QueryPage::getOrderFields().
+        * Do NOT change this to true unless you remove the phrase DESC in getOrderFiels above.
+        * If you do a database error will be thrown due to double adding DESC to query!
+        *
+        * @return bool
+        * @since 1.29
+        */
+       function sortDescending() {
+               return false;
+       }
+
+       /**
+        * Also use the order fields returned by getOrderFields when fetching from the cache.
+        * @return array
+        * @since 1.29
+        */
+       function getCacheOrderFields() {
+               return $this->getOrderFields();
+       }
+
 }