Merge "ResourceLoaderLanguageDataModule: Clean up useless methods and fragile state"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 1 May 2014 06:21:27 +0000 (06:21 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 1 May 2014 06:21:27 +0000 (06:21 +0000)
15 files changed:
RELEASE-NOTES-1.24
docs/hooks.txt
includes/AutoLoader.php
includes/db/Database.php
includes/resourceloader/ResourceLoaderLanguageNamesModule.php [new file with mode: 0644]
includes/specials/SpecialSearch.php
includes/specials/SpecialWhatlinkshere.php
resources/Resources.php
resources/lib/oojs-ui/i18n/br.json
resources/lib/oojs-ui/oojs-ui.js
resources/lib/oojs-ui/oojs-ui.svg.css
resources/src/jquery/jquery.byteLength.js
resources/src/jquery/jquery.hidpi.js
resources/src/mediawiki.ui/components/default/buttons.less
tests/phpunit/includes/db/DatabaseTestHelper.php

index 42eadaa..aaabb6b 100644 (file)
@@ -11,6 +11,8 @@ production.
 === Configuration changes in 1.24 ===
 
 === New features in 1.24 ===
+* Added a new hook, "WhatLinksHereProps", to allow extensions to annotate
+  WhatLinksHere entries.
 
 === Bug fixes in 1.24 ===
 * (bug 62258) A bug was fixed in File::getUnscaledThumb when a height
index 80f388b..688e0cd 100644 (file)
@@ -2922,6 +2922,12 @@ Return false to prevent setting of the cookie.
 &$expire: Cookie expiration, as for PHP's setcookie()
 $options: Options passed to WebResponse::setcookie()
 
+'WhatLinksHereProps': Allows annotations to be added to WhatLinksHere
+$row: The DB row of the entry.
+$title: The Title of the page where the link comes FROM
+$target: The Title of the page where the link goes TO
+&$props: Array of HTML strings to display after the title.
+
 'WikiExporter::dumpStableQuery': Get the SELECT query for "stable" revisions
 dumps. One, and only one hook should set this, and return false.
 &$tables: Database tables to use in the SELECT query
index 73b1577..d7416ec 100644 (file)
@@ -870,6 +870,8 @@ $wgAutoloadLocalClasses = array(
        'ResourceLoaderUserTokensModule' => 'includes/resourceloader/ResourceLoaderUserTokensModule.php',
        'ResourceLoaderLanguageDataModule' =>
                'includes/resourceloader/ResourceLoaderLanguageDataModule.php',
+       'ResourceLoaderLanguageNamesModule' =>
+               'includes/resourceloader/ResourceLoaderLanguageNamesModule.php',
        'ResourceLoaderWikiModule' => 'includes/resourceloader/ResourceLoaderWikiModule.php',
 
        # includes/revisiondelete
index b502bb9..8288e65 100644 (file)
@@ -1088,6 +1088,11 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
 
                $queryId = MWDebug::query( $sql, $fname, $isMaster );
 
+               # Avoid fatals if close() was called
+               if ( !$this->isOpen() ) {
+                       throw new DBUnexpectedError( $this, "DB connection was already closed." );
+               }
+
                # Do the query and handle errors
                $ret = $this->doQuery( $commentedSql );
 
diff --git a/includes/resourceloader/ResourceLoaderLanguageNamesModule.php b/includes/resourceloader/ResourceLoaderLanguageNamesModule.php
new file mode 100644 (file)
index 0000000..73b6ea7
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Resource loader module for providing language names.
+ *
+ * By default these names will be autonyms however other extensions may
+ * provided language names in the context language (e.g. cldr extension)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @author Ed Sanders
+ * @author Trevor Parscal
+ */
+
+/**
+ * ResourceLoader module for populating language specific data.
+ */
+class ResourceLoaderLanguageNamesModule extends ResourceLoaderModule {
+
+       protected $targets = array( 'desktop', 'mobile' );
+
+
+       /**
+        * @param $context ResourceLoaderContext
+        * @return array
+        */
+       protected function getData( ResourceLoaderContext $context ) {
+               return Language::fetchLanguageNames(
+                       $context->getLanguage(),
+                       'all'
+               );
+       }
+
+       /**
+        * @param $context ResourceLoaderContext
+        * @return string JavaScript code
+        */
+       public function getScript( ResourceLoaderContext $context ) {
+               return Xml::encodeJsCall( 'mw.language.setData', array(
+                       $context->getLanguage(),
+                       'languageNames',
+                       $this->getData( $context )
+               ) );
+       }
+
+       public function getDependencies() {
+               return array( 'mediawiki.language.init' );
+       }
+
+       /**
+        * @param ResourceLoaderContext $context
+        * @return int UNIX timestamp
+        */
+       public function getModifiedTime( ResourceLoaderContext $context ) {
+               return max( 1, $this->getHashMtime( $context ) );
+       }
+
+       /**
+        * @param ResourceLoaderContext $context
+        * @return string Hash
+        */
+       public function getModifiedHash( ResourceLoaderContext $context ) {
+               return md5( serialize( $this->getData( $context ) ) );
+       }
+
+}
index 0c4252e..6eee861 100644 (file)
@@ -360,14 +360,16 @@ class SpecialSearch extends SpecialPage {
                $out->addHtml( "<div class='searchresults'>" );
 
                // prev/next links
+               $prevnext = null;
                if ( $num || $this->offset ) {
                        // Show the create link ahead
                        $this->showCreateLink( $title, $num, $titleMatches, $textMatches );
-                       $prevnext = $this->getLanguage()->viewPrevNext( $this->getPageTitle(), $this->offset, $this->limit,
-                               $this->powerSearchOptions() + array( 'search' => $term ),
-                               max( $titleMatchesNum, $textMatchesNum ) < $this->limit
-                       );
-                       //$out->addHTML( "<p class='mw-search-pager-top'>{$prevnext}</p>\n" );
+                       if ( $totalRes > $this->limit || $this->offset ) {
+                               $prevnext = $this->getLanguage()->viewPrevNext( $this->getPageTitle(), $this->offset, $this->limit,
+                                       $this->powerSearchOptions() + array( 'search' => $term ),
+                                       max( $titleMatchesNum, $textMatchesNum ) < $this->limit
+                               );
+                       }
                        wfRunHooks( 'SpecialSearchResults', array( $term, &$titleMatches, &$textMatches ) );
                } else {
                        wfRunHooks( 'SpecialSearchNoResults', array( $term ) );
@@ -386,10 +388,8 @@ class SpecialSearch extends SpecialPage {
                        if ( $numTextMatches > 0 && $numTitleMatches > 0 ) {
                                // if no title matches the heading is redundant
                                $out->wrapWikiMsg( "==$1==\n", 'textmatches' );
-                       } elseif ( $totalRes == 0 ) {
-                               # Don't show the 'no text matches' if we received title matches
-                               # $out->wrapWikiMsg( "==$1==\n", 'notextmatches' );
                        }
+
                        // show interwiki results if any
                        if ( $textMatches->hasInterwikiResults() ) {
                                $out->addHTML( $this->showInterwiki( $textMatches->getInterwikiResults(), $term ) );
@@ -413,7 +413,7 @@ class SpecialSearch extends SpecialPage {
                }
                $out->addHtml( "</div>" );
 
-               if ( $num || $this->offset ) {
+               if ( $prevnext ) {
                        $out->addHTML( "<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" );
                }
        }
index 0587649..6488810 100644 (file)
@@ -265,11 +265,11 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                        $nt = Title::makeTitle( $row->page_namespace, $row->page_title );
 
                        if ( $row->rd_from && $level < 2 ) {
-                               $out->addHTML( $this->listItem( $row, $nt, true ) );
+                               $out->addHTML( $this->listItem( $row, $nt, $target, true ) );
                                $this->showIndirectLinks( $level + 1, $nt, $wgMaxRedirectLinksRetrieved );
                                $out->addHTML( Xml::closeElement( 'li' ) );
                        } else {
-                               $out->addHTML( $this->listItem( $row, $nt ) );
+                               $out->addHTML( $this->listItem( $row, $nt, $target ) );
                        }
                }
 
@@ -286,7 +286,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                return Xml::openElement( 'ul', ( $level ? array() : array( 'id' => 'mw-whatlinkshere-list' ) ) );
        }
 
-       protected function listItem( $row, $nt, $notClose = false ) {
+       protected function listItem( $row, $nt, $target, $notClose = false ) {
                $dirmark = $this->getLanguage()->getDirMark();
 
                # local message cache
@@ -326,6 +326,8 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                        $props[] = $msgcache['isimage'];
                }
 
+               wfRunHooks( 'WhatLinksHereProps', array( $row, $nt, $target, &$props ) );
+
                if ( count( $props ) ) {
                        $propsText = $this->msg( 'parentheses' )
                                ->rawParams( implode( $msgcache['semicolon-separator'], $props ) )->escaped();
index 668dc14..e5e87f4 100644 (file)
@@ -1069,6 +1069,8 @@ return array(
                )
        ),
 
+       'mediawiki.language.names' => array( 'class' => 'ResourceLoaderLanguageNamesModule' ),
+
        /* MediaWiki Libs */
 
        'mediawiki.libs.jpegmeta' => array(
index 137322a..44247ca 100644 (file)
@@ -8,5 +8,7 @@
        },
        "ooui-dialog-action-close": "Serriñ",
        "ooui-outline-control-move-down": "Lakaat an elfenn da ziskenn",
-       "ooui-outline-control-move-up": "Lakaat an elfenn da bignat"
+       "ooui-outline-control-move-up": "Lakaat an elfenn da bignat",
+       "ooui-outline-control-remove": "Tennañ an elfenn",
+       "ooui-toolbar-more": "Muioc'h"
 }
index d965ffa..92d7378 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.1.0-pre (70f1886a35)
+ * OOjs UI v0.1.0-pre (bdbb9cfa55)
  * https://www.mediawiki.org/wiki/OOjs_UI
  *
  * Copyright 2011–2014 OOjs Team and other contributors.
  * Released under the MIT license
  * http://oojs.mit-license.org
  *
- * Date: Tue Apr 29 2014 17:13:10 GMT-0700 (PDT)
+ * Date: Wed Apr 30 2014 16:34:11 GMT-0700 (PDT)
  */
 ( function ( OO ) {
 
@@ -5768,6 +5768,15 @@ OO.ui.LookupInputWidget.prototype.onLookupInputChange = function () {
        this.openLookupMenu();
 };
 
+/**
+ * Get lookup menu.
+ *
+ * @return {OO.ui.TextInputMenuWidget}
+ */
+OO.ui.LookupInputWidget.prototype.getLookupMenu = function () {
+       return this.lookupMenu;
+};
+
 /**
  * Open the menu.
  *
@@ -6096,24 +6105,26 @@ OO.ui.OptionWidget.prototype.setPressed = function ( state ) {
  *
  * While flashing, the visual style of the pressed state is removed if present.
  *
- * @param {Function} [done] Callback to execute when flash effect is complete.
+ * @return {jQuery.Promise} Promise resolved when flashing is done
  */
-OO.ui.OptionWidget.prototype.flash = function ( done ) {
-       var $this = this.$element;
+OO.ui.OptionWidget.prototype.flash = function () {
+       var $this = this.$element,
+               deferred = $.Deferred();
 
        if ( !this.disabled && this.constructor.static.pressable ) {
                $this.removeClass( 'oo-ui-optionWidget-highlighted oo-ui-optionWidget-pressed' );
                setTimeout( OO.ui.bind( function () {
-                       $this.addClass( 'oo-ui-optionWidget-highlighted' );
-                       if ( done ) {
-                               // Restore original classes
-                               $this
-                                       .toggleClass( 'oo-ui-optionWidget-highlighted', this.highlighted )
-                                       .toggleClass( 'oo-ui-optionWidget-pressed', this.pressed );
-                               setTimeout( done, 100 );
-                       }
+                       // Restore original classes
+                       $this
+                               .toggleClass( 'oo-ui-optionWidget-highlighted', this.highlighted )
+                               .toggleClass( 'oo-ui-optionWidget-pressed', this.pressed );
+                       setTimeout( function () {
+                               deferred.resolve();
+                       }, 100 );
                }, this ), 100 );
        }
+
+       return deferred.promise();
 };
 
 /**
@@ -6784,7 +6795,7 @@ OO.ui.MenuWidget.prototype.chooseItem = function ( item ) {
 
        if ( item && !this.flashing ) {
                this.flashing = true;
-               item.flash( OO.ui.bind( function () {
+               item.flash().done( OO.ui.bind( function () {
                        this.hide();
                        this.flashing = false;
                }, this ) );
index d19eb80..3a5268d 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.1.0-pre (70f1886a35)
+ * OOjs UI v0.1.0-pre (bdbb9cfa55)
  * https://www.mediawiki.org/wiki/OOjs_UI
  *
  * Copyright 2011–2014 OOjs Team and other contributors.
  * Released under the MIT license
  * http://oojs.mit-license.org
  *
- * Date: Tue Apr 29 2014 17:13:10 GMT-0700 (PDT)
+ * Date: Wed Apr 30 2014 16:34:11 GMT-0700 (PDT)
  */
 
 /* Textures */
index 0b8f9da..7fe25ee 100644 (file)
@@ -9,6 +9,9 @@
  * Calculate the byte length of a string (accounting for UTF-8).
  *
  * @static
+ * @inheritable
+ * @param {string} str
+ * @return {string}
  */
 jQuery.byteLength = function ( str ) {
        // This basically figures out how many bytes a UTF-16 string (which is what js sees)
index 99889f1..71b083b 100644 (file)
@@ -21,6 +21,7 @@
  * Uses `window.devicePixelRatio` if available, or CSS media queries on IE.
  *
  * @static
+ * @inheritable
  * @return {number} Device pixel ratio
  */
 $.devicePixelRatio = function () {
index f7a7eae..78b0b33 100644 (file)
@@ -31,6 +31,9 @@
        margin: 0;
        .box-sizing(border-box);
 
+       // Disable weird iOS styling
+       -webkit-appearance: none;
+
        // IE6/IE7 hack
        // http://stackoverflow.com/a/5838575/365238
        *display: inline;
index 790f273..39c311f 100644 (file)
@@ -156,6 +156,10 @@ class DatabaseTestHelper extends DatabaseBase {
                return 'test';
        }
 
+       function isOpen() {
+               return true;
+       }
+
        protected function closeConnection() {
                return false;
        }