Merge "Add .gitignore to the /skins directory"
[lhc/web/wiklou.git] / includes / api / ApiQueryLangLinks.php
index ac65d2d..a20b855 100644 (file)
@@ -67,27 +67,28 @@ class ApiQueryLangLinks extends ApiQueryBase {
                        );
                }
 
-                       $sort = ( $params['dir'] == 'descending' ? ' DESC' : '' );
-                       if ( isset( $params['lang'] ) ) {
+               //FIXME: (follow-up) To allow extensions to add to the language links, we need
+               //       to load them all, add the extra links, then apply paging.
+               //       Should not be terrible, it's not going to be more than a few hundred links.
+
+               // Note that, since (ll_from, ll_lang) is a unique key, we don't need
+               // to sort by ll_title to ensure deterministic ordering.
+               $sort = ( $params['dir'] == 'descending' ? ' DESC' : '' );
+               if ( isset( $params['lang'] ) ) {
                        $this->addWhereFld( 'll_lang', $params['lang'] );
                        if ( isset( $params['title'] ) ) {
                                $this->addWhereFld( 'll_title', $params['title'] );
-                               $this->addOption( 'ORDER BY', 'll_from' . $sort );
-                       } else {
-                               $this->addOption( 'ORDER BY', array(
-                                                       'll_title' . $sort,
-                                                       'll_from' . $sort
-                               ));
                        }
+                       $this->addOption( 'ORDER BY', 'll_from' . $sort );
                } else {
                        // Don't order by ll_from if it's constant in the WHERE clause
                        if ( count( $this->getPageSet()->getGoodTitles() ) == 1 ) {
                                $this->addOption( 'ORDER BY', 'll_lang' . $sort );
                        } else {
                                $this->addOption( 'ORDER BY', array(
-                                                       'll_from' . $sort,
-                                                       'll_lang' . $sort
-                               ));
+                                       'll_from' . $sort,
+                                       'll_lang' . $sort
+                               ) );
                        }
                }
 
@@ -181,7 +182,8 @@ class ApiQueryLangLinks extends ApiQueryBase {
 
        public function getExamples() {
                return array(
-                       'api.php?action=query&prop=langlinks&titles=Main%20Page&redirects=' => 'Get interlanguage links from the [[Main Page]]',
+                       'api.php?action=query&prop=langlinks&titles=Main%20Page&redirects='
+                               => 'Get interlanguage links from the [[Main Page]]',
                );
        }