Merge "(bug 38152) jquery.tablesorter: Use .data() instead of .attr()"
authorKaldari <rkaldari@wikimedia.org>
Thu, 5 Jul 2012 00:54:19 +0000 (00:54 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 5 Jul 2012 00:54:19 +0000 (00:54 +0000)
RELEASE-NOTES-1.20
docs/hooks.txt
includes/api/ApiQueryBacklinks.php
includes/api/ApiQueryIWBacklinks.php
includes/api/ApiQueryLangBacklinks.php
includes/parser/Parser.php
maintenance/cleanupPreferences.php [new file with mode: 0755]
resources/mediawiki/mediawiki.user.js

index d70b042..88b9412 100644 (file)
@@ -84,6 +84,11 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki.
   "mw-changeslist-line-watched" or "mw-changeslist-line-not-watched", and the
   title itself is surrounded by <span></span> tags with class "mw-title".
 * Added ContribsPager::reallyDoQuery hook allowing extensions to data to MyContribs
+* Added new hook ParserAfterParse to allow extensions to affect parsed output
+  after the parse is complete but before block level processing, link holder
+  replacement, and so on.
+* (bug 34678) Added InternalParseBeforeSanitize hook which gets called during Parser's
+  internalParse method just before the parser removes unwanted/dangerous HTML tags.
 
 === Bug fixes in 1.20 ===
 * (bug 30245) Use the correct way to construct a log page title.
@@ -172,6 +177,9 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki.
 * The paraminfo module now also contains result properties for most modules
 * (bug 32348) Allow descending order for list=alllinks
 * (bug 31777) Upload unknown error ``fileexists-forbidden''
+* (bug 32382) Allow descending order for list=iwbacklinks
+* (bug 32381) Allow descending order for list=backlinks, list=embeddedin and list=imageusage
+* (bug 32383) Allow descending order for list=langbacklinks
 
 === Languages updated in 1.20 ===
 
index 9dec097..70c334a 100644 (file)
@@ -1129,8 +1129,16 @@ $prefix: interwiki prefix we are looking for.
 &$iwData: output array describing the interwiki with keys iw_url, iw_local,
   iw_trans and optionally iw_api and iw_wikiid.
 
+'InternalParseBeforeSanitize': during Parser's internalParse method just before the
+parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/
+onlyinclude and other processings. Ideal for syntax-extensions after template/parser
+function execution which respect nowiki and HTML-comments.
+&$parser: Parser object
+&$text: string containing partially parsed text
+&$stripState: Parser's internal StripState object
+
 'InternalParseBeforeLinks': during Parser's internalParse method before links
-but after noinclude/includeonly/onlyinclude and other processing.
+but after nowiki/noinclude/includeonly/onlyinclude and other processings.
 &$parser: Parser object
 &$text: string containing partially parsed text
 &$stripState: Parser's internal StripState object
@@ -1470,6 +1478,12 @@ A parser extension which depends on user options should install
 this hook and append its values to the key.
 $hash: reference to a hash key string which can be modified
 
+'ParserAfterParse': Called from Parser::parse() just after the call to
+Parser::internalParse() returns
+$parser: parser object
+$text: text being parsed
+$stripState: stripState used (object)
+
 'ParserAfterStrip': Same as ParserBeforeStrip
 
 'ParserAfterTidy': Called after Parser::tidy() in Parser::parse()
index 9704b6d..7491bbb 100644 (file)
@@ -40,7 +40,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
        private $rootTitle;
 
        private $params, $contID, $redirID, $redirect;
-       private $bl_ns, $bl_from, $bl_table, $bl_code, $bl_title, $bl_sort, $bl_fields, $hasNS;
+       private $bl_ns, $bl_from, $bl_table, $bl_code, $bl_title, $bl_fields, $hasNS;
 
        /**
         * Maps ns and title to pageid
@@ -91,14 +91,12 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                $this->hasNS = $moduleName !== 'imageusage';
                if ( $this->hasNS ) {
                        $this->bl_title = $prefix . '_title';
-                       $this->bl_sort = "{$this->bl_ns}, {$this->bl_title}, {$this->bl_from}";
                        $this->bl_fields = array(
                                $this->bl_ns,
                                $this->bl_title
                        );
                } else {
                        $this->bl_title = $prefix . '_to';
-                       $this->bl_sort = "{$this->bl_title}, {$this->bl_from}";
                        $this->bl_fields = array(
                                $this->bl_title
                        );
@@ -144,7 +142,8 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                $this->addWhereFld( 'page_namespace', $this->params['namespace'] );
 
                if ( !is_null( $this->contID ) ) {
-                       $this->addWhere( "{$this->bl_from}>={$this->contID}" );
+                       $op = $this->params['dir'] == 'descending' ? '<' : '>';
+                       $this->addWhere( "{$this->bl_from}$op={$this->contID}" );
                }
 
                if ( $this->params['filterredir'] == 'redirects' ) {
@@ -155,7 +154,8 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                }
 
                $this->addOption( 'LIMIT', $this->params['limit'] + 1 );
-               $this->addOption( 'ORDER BY', $this->bl_from );
+               $sort = ( $this->params['dir'] == 'descending' ? ' DESC' : '' );
+               $this->addOption( 'ORDER BY', $this->bl_from . $sort );
                $this->addOption( 'STRAIGHT_JOIN' );
        }
 
@@ -186,28 +186,35 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
 
                // We can't use LinkBatch here because $this->hasNS may be false
                $titleWhere = array();
+               $allRedirNs = array();
+               $allRedirDBkey = array();
                foreach ( $this->redirTitles as $t ) {
-                       $titleWhere[] = "{$this->bl_title} = " . $db->addQuotes( $t->getDBkey() ) .
-                                       ( $this->hasNS ? " AND {$this->bl_ns} = {$t->getNamespace()}" : '' );
+                       $redirNs = $t->getNamespace();
+                       $redirDBkey = $t->getDBkey();
+                       $titleWhere[] = "{$this->bl_title} = " . $db->addQuotes( $redirDBkey ) .
+                                       ( $this->hasNS ? " AND {$this->bl_ns} = {$redirNs}" : '' );
+                       $allRedirNs[] = $redirNs;
+                       $allRedirDBkey[] = $redirDBkey;
                }
                $this->addWhere( $db->makeList( $titleWhere, LIST_OR ) );
                $this->addWhereFld( 'page_namespace', $this->params['namespace'] );
 
                if ( !is_null( $this->redirID ) ) {
+                       $op = $this->params['dir'] == 'descending' ? '<' : '>';
                        $first = $this->redirTitles[0];
                        $title = $db->addQuotes( $first->getDBkey() );
                        $ns = $first->getNamespace();
                        $from = $this->redirID;
                        if ( $this->hasNS ) {
-                               $this->addWhere( "{$this->bl_ns} > $ns OR " .
+                               $this->addWhere( "{$this->bl_ns} $op $ns OR " .
                                                "({$this->bl_ns} = $ns AND " .
-                                               "({$this->bl_title} > $title OR " .
+                                               "({$this->bl_title} $op $title OR " .
                                                "({$this->bl_title} = $title AND " .
-                                               "{$this->bl_from} >= $from)))" );
+                                               "{$this->bl_from} $op= $from)))" );
                        } else {
-                               $this->addWhere( "{$this->bl_title} > $title OR " .
+                               $this->addWhere( "{$this->bl_title} $op $title OR " .
                                                "({$this->bl_title} = $title AND " .
-                                               "{$this->bl_from} >= $from)" );
+                                               "{$this->bl_from} $op= $from)" );
                        }
                }
                if ( $this->params['filterredir'] == 'redirects' ) {
@@ -217,7 +224,17 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                }
 
                $this->addOption( 'LIMIT', $this->params['limit'] + 1 );
-               $this->addOption( 'ORDER BY', $this->bl_sort );
+               $orderBy = array();
+               $sort = ( $this->params['dir'] == 'descending' ? ' DESC' : '' );
+               // Don't order by namespace/title if it's constant in the WHERE clause
+               if( $this->hasNS && count( array_unique( $allRedirNs ) ) != 1 ) {
+                       $orderBy[] = $this->bl_ns . $sort;
+               }
+               if( count( array_unique( $allRedirDBkey ) ) != 1 ) {
+                       $orderBy[] = $this->bl_title . $sort;
+               }
+               $orderBy[] = $this->bl_from . $sort;
+               $this->addOption( 'ORDER BY', $orderBy );
                $this->addOption( 'USE INDEX', array( 'page' => 'PRIMARY' ) );
        }
 
@@ -438,6 +455,13 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                                ApiBase::PARAM_ISMULTI => true,
                                ApiBase::PARAM_TYPE => 'namespace'
                        ),
+                       'dir' => array(\r
+                               ApiBase::PARAM_DFLT => 'ascending',\r
+                               ApiBase::PARAM_TYPE => array(\r
+                                       'ascending',\r
+                                       'descending'\r
+                               )\r
+                       ),
                        'filterredir' => array(
                                ApiBase::PARAM_DFLT => 'all',
                                ApiBase::PARAM_TYPE => array(
@@ -467,6 +491,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                        'pageid' => "Pageid to search. Cannot be used together with {$this->bl_code}title",
                        'continue' => 'When more results are available, use this to continue',
                        'namespace' => 'The namespace to enumerate',
+                       'dir' => 'The direction in which to list',
                );
                if ( $this->getModuleName() != 'embeddedin' ) {
                        return array_merge( $retval, array(
index d2837e9..37f347d 100644 (file)
@@ -62,15 +62,16 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase {
                        }
 
                        $db = $this->getDB();
+                       $op = $params['dir'] == 'descending' ? '<' : '>';
                        $prefix = $db->addQuotes( $cont[0] );
                        $title = $db->addQuotes( $this->titleToKey( $cont[1] ) );
                        $from = intval( $cont[2] );
                        $this->addWhere(
-                               "iwl_prefix > $prefix OR " .
+                               "iwl_prefix $op $prefix OR " .
                                "(iwl_prefix = $prefix AND " .
-                               "(iwl_title > $title OR " .
+                               "(iwl_title $op $title OR " .
                                "(iwl_title = $title AND " .
-                               "iwl_from >= $from)))"
+                               "iwl_from $op= $from)))"
                        );
                }
 
@@ -84,22 +85,23 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase {
                $this->addFields( array( 'page_id', 'page_title', 'page_namespace', 'page_is_redirect',
                        'iwl_from', 'iwl_prefix', 'iwl_title' ) );
 
+               $sort = ( $params['dir'] == 'descending' ? ' DESC' : '' );
                if ( isset( $params['prefix'] ) ) {
                        $this->addWhereFld( 'iwl_prefix', $params['prefix'] );
                        if ( isset( $params['title'] ) ) {
                                $this->addWhereFld( 'iwl_title', $params['title'] );
-                               $this->addOption( 'ORDER BY', 'iwl_from' );
+                               $this->addOption( 'ORDER BY', 'iwl_from' . $sort );
                        } else {
                                $this->addOption( 'ORDER BY', array(
-                                       'iwl_title',
-                                       'iwl_from'
+                                       'iwl_title' . $sort,
+                                       'iwl_from' . $sort
                                ));
                        }
                } else {
                        $this->addOption( 'ORDER BY', array(
-                               'iwl_prefix',
-                               'iwl_title',
-                               'iwl_from'
+                               'iwl_prefix' . $sort,
+                               'iwl_title' . $sort,
+                               'iwl_from' . $sort
                        ));
                }
 
@@ -178,6 +180,13 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase {
                                        'iwtitle',
                                ),
                        ),
+                       'dir' => array(
+                               ApiBase::PARAM_DFLT => 'ascending',
+                               ApiBase::PARAM_TYPE => array(
+                                       'ascending',
+                                       'descending'
+                               )
+                       ),
                );
        }
 
@@ -192,6 +201,7 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase {
                                ' iwtitle        - Adds the title of the interwiki',
                        ),
                        'limit' => 'How many total pages to return',
+                       'dir' => 'The direction in which to list',
                );
        }
 
index f423719..c7639ee 100644 (file)
@@ -62,15 +62,16 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase {
                        }
 
                        $db = $this->getDB();
+                       $op = $params['dir'] == 'descending' ? '<' : '>';
                        $prefix = $db->addQuotes( $cont[0] );
                        $title = $db->addQuotes( $this->titleToKey( $cont[1] ) );
                        $from = intval( $cont[2] );
                        $this->addWhere(
-                               "ll_lang > $prefix OR " .
+                               "ll_lang $op $prefix OR " .
                                "(ll_lang = $prefix AND " .
-                               "(ll_title > $title OR " .
+                               "(ll_title $op $title OR " .
                                "(ll_title = $title AND " .
-                               "ll_from >= $from)))"
+                               "ll_from $op= $from)))"
                        );
                }
 
@@ -84,22 +85,23 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase {
                $this->addFields( array( 'page_id', 'page_title', 'page_namespace', 'page_is_redirect',
                        'll_from', 'll_lang', 'll_title' ) );
 
+               $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' );
+                               $this->addOption( 'ORDER BY', 'll_from' . $sort );
                        } else {
                                $this->addOption( 'ORDER BY', array(
-                                       'll_title',
-                                       'll_from'
+                                       'll_title' . $sort,
+                                       'll_from' . $sort
                                ));
                        }
                } else {
                        $this->addOption( 'ORDER BY', array(
-                               'll_lang',
-                               'll_title',
-                               'll_from'
+                               'll_lang' . $sort,
+                               'll_title' . $sort,
+                               'll_from' . $sort
                        ));
                }
 
@@ -178,6 +180,13 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase {
                                        'lltitle',
                                ),
                        ),
+                       'dir' => array(
+                               ApiBase::PARAM_DFLT => 'ascending',
+                               ApiBase::PARAM_TYPE => array(
+                                       'ascending',
+                                       'descending'
+                               )
+                       ),
                );
        }
 
@@ -192,6 +201,7 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase {
                                ' lltitle        - Adds the title of the language ink',
                        ),
                        'limit' => 'How many total pages to return',
+                       'dir' => 'The direction in which to list',
                );
        }
 
index 7bd2aab..7991ca6 100644 (file)
@@ -364,6 +364,7 @@ class Parser {
                # No more strip!
                wfRunHooks( 'ParserAfterStrip', array( &$this, &$text, &$this->mStripState ) );
                $text = $this->internalParse( $text );
+               wfRunHooks( 'ParserAfterParse', array( &$this, &$text, &$this->mStripState ) );
 
                $text = $this->mStripState->unstripGeneral( $text );
 
@@ -1121,6 +1122,7 @@ class Parser {
                        $text = $this->replaceVariables( $text );
                }
 
+               wfRunHooks( 'InternalParseBeforeSanitize', array( &$this, &$text, &$this->mStripState ) );
                $text = Sanitizer::removeHTMLtags( $text, array( &$this, 'attributeStripCallback' ), false, array_keys( $this->mTransparentTagHooks ) );
                wfRunHooks( 'InternalParseBeforeLinks', array( &$this, &$text, &$this->mStripState ) );
 
diff --git a/maintenance/cleanupPreferences.php b/maintenance/cleanupPreferences.php
new file mode 100755 (executable)
index 0000000..57a5369
--- /dev/null
@@ -0,0 +1,29 @@
+<?php\r
+/**\r
+ * Description: This script takes $wgHiddenPrefs and removes their preference from the DB. [[bugzilla:30976]]\r
+ * @author TyA <tya.wiki@gmail.com>\r
+ * @ingroup Maintenance\r
+ */\r
+\r
+require_once( dirname( __FILE__ ) . '/Maintenance.php' );\r
+\r
+class CleanupPreferences extends Maintenance {\r
+       public function execute() {\r
+               global $wgHiddenPrefs;\r
+\r
+               $dbw = wfGetDB( DB_MASTER );\r
+               $dbw->begin();\r
+               foreach( $wgHiddenPrefs as $item ) {\r
+                       $dbw->delete(\r
+                               'user_properties',\r
+                               array( 'up_property' => $item ),\r
+                               __METHOD__\r
+                       );\r
+               };\r
+               $dbw->commit();\r
+               $this->output( "Finished!\n" );\r
+       }\r
+}\r
+\r
+$maintClass = 'CleanupPreferences'; // Tells it to run the class\r
+require_once( RUN_MAINTENANCE_IF_MAIN );\r
index 7f881b0..7a15e29 100644 (file)
@@ -25,7 +25,7 @@
                 * Generates a random user session ID (32 alpha-numeric characters).
                 *
                 * This information would potentially be stored in a cookie to identify a user during a
-                * session or series of sessions. It's uniqueness should not be depended on.
+                * session or series of sessions. Its uniqueness should not be depended on.
                 *
                 * @return String: Random set of 32 alpha-numeric characters
                 */
        // This is kind of ugly but we're stuck with this for b/c reasons
        mw.user = new User( mw.user.options, mw.user.tokens );
 
-})(jQuery);
\ No newline at end of file
+})(jQuery);