Index: trunk/phase3/maintenance/cleanupRemovedModules.php |
— | — | @@ -0,0 +1,83 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Maintenance script to create an account and grant it administrator rights |
| 5 | + * |
| 6 | + * This program is free software; you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU General Public License as published by |
| 8 | + * the Free Software Foundation; either version 2 of the License, or |
| 9 | + * (at your option) any later version. |
| 10 | + * |
| 11 | + * This program is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | + * GNU General Public License for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU General Public License along |
| 17 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 18 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 19 | + * http://www.gnu.org/copyleft/gpl.html |
| 20 | + * |
| 21 | + * @file |
| 22 | + * @ingroup Maintenance |
| 23 | + * @author Rob Church <robchur@gmail.com> |
| 24 | + */ |
| 25 | + |
| 26 | +require_once( dirname( __FILE__ ) . '/Maintenance.php' ); |
| 27 | + |
| 28 | +class CleanupRemovedModules extends Maintenance { |
| 29 | + |
| 30 | + public function __construct() { |
| 31 | + parent::__construct(); |
| 32 | + $this->mDescription = 'Remove cache entries for removed ResourceLoader modules from the database'; |
| 33 | + $this->addOption( 'batchsize', 'Delete rows in batches of this size. Default: 500', false, true ); |
| 34 | + $this->addOption( 'max-slave-lag', 'If the slave lag exceeds this many seconds, wait until it drops below this value. Default: 5', false, true ); |
| 35 | + } |
| 36 | + |
| 37 | + public function execute() { |
| 38 | + $dbw = wfGetDB( DB_MASTER ); |
| 39 | + $rl = new ResourceLoader(); |
| 40 | + $moduleNames = array_keys( $rl->getModules() ); |
| 41 | + $moduleList = implode( ', ', array_map( array( $dbw, 'addQuotes' ), $moduleNames ) ); |
| 42 | + $limit = min( 1, intval( $this->getOption( 'batchsize', 500 ) ) ); |
| 43 | + $maxlag = intval( $this->getOption( 'max-slave-lag', 5 ) ); |
| 44 | + |
| 45 | + $this->output( "Cleaning up module_deps table...\n" ); |
| 46 | + $i = 1; |
| 47 | + do { |
| 48 | + // $dbw->delete() doesn't support LIMIT :( |
| 49 | + $dbw->query( "DELETE FROM module_deps WHERE md_module NOT IN ($moduleList) LIMIT $limit", __METHOD__ ); |
| 50 | + $numRows = $dbw->affectedRows(); |
| 51 | + $this->output( "Batch $i: $numRows rows\n" ); |
| 52 | + $i++; |
| 53 | + wfWaitForSlaves( $maxlag ); |
| 54 | + } while( $dbw->affectedRows() > 0 ); |
| 55 | + $this->output( "done\n" ); |
| 56 | + |
| 57 | + $this->output( "Cleaning up msg_resource table...\n" ); |
| 58 | + $i = 1; |
| 59 | + do { |
| 60 | + // $dbw->delete() doesn't support LIMIT :( |
| 61 | + $dbw->query( "DELETE FROM msg_resource WHERE mr_resource NOT IN ($moduleList) LIMIT $limit", __METHOD__ ); |
| 62 | + $numRows = $dbw->affectedRows(); |
| 63 | + $this->output( "Batch $i: $numRows rows\n" ); |
| 64 | + $i++; |
| 65 | + wfWaitForSlaves( $maxlag ); |
| 66 | + } while( $dbw->affectedRows() > 0 ); |
| 67 | + $this->output( "done\n" ); |
| 68 | + |
| 69 | + $this->output( "Cleaning up msg_resource_links table...\n" ); |
| 70 | + $i = 1; |
| 71 | + do { |
| 72 | + // $dbw->delete() doesn't support LIMIT :( |
| 73 | + $dbw->query( "DELETE FROM msg_resource_links WHERE mrl_resource NOT IN ($moduleList) LIMIT $limit", __METHOD__ ); |
| 74 | + $numRows = $dbw->affectedRows(); |
| 75 | + $this->output( "Batch $i: $numRows rows\n" ); |
| 76 | + $i++; |
| 77 | + wfWaitForSlaves( $maxlag ); |
| 78 | + } while( $dbw->affectedRows() > 0 ); |
| 79 | + $this->output( "done\n" ); |
| 80 | + } |
| 81 | +} |
| 82 | + |
| 83 | +$maintClass = "CleanupRemovedModules"; |
| 84 | +require_once( DO_MAINTENANCE ); |
\ No newline at end of file |
Property changes on: trunk/phase3/maintenance/cleanupRemovedModules.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 85 | + native |
Index: trunk/phase3/resources/mediawiki/mediawiki.js |
— | — | @@ -249,7 +249,7 @@ |
250 | 250 | this.message = function( key, parameters ) { |
251 | 251 | // Support variadic arguments |
252 | 252 | if ( typeof parameters !== 'undefined' ) { |
253 | | - parameters = $.makeArray( arguments); |
| 253 | + parameters = $.makeArray( arguments ); |
254 | 254 | parameters.shift(); |
255 | 255 | } else { |
256 | 256 | parameters = []; |
Index: trunk/phase3/resources/mediawiki.language/mediawiki.language.js |
— | — | @@ -18,9 +18,9 @@ |
19 | 19 | * @example {{Template:title|params}} |
20 | 20 | */ |
21 | 21 | 'procPLURAL': function( template ) { |
22 | | - if( template.title && template.parameters && mediaWiki.language.convertPlural) { |
| 22 | + if ( template.title && template.parameters && mediaWiki.language.convertPlural ) { |
23 | 23 | // Check if we have forms to replace |
24 | | - if ( template.parameters.length == 0 ) { |
| 24 | + if ( template.parameters.length == 0 ) { |
25 | 25 | return ''; |
26 | 26 | } |
27 | 27 | // Restore the count into a Number ( if it got converted earlier ) |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | return mediaWiki.language.convertPlural( parseInt( count ), template.parameters ); |
31 | 31 | } |
32 | 32 | // Could not process plural return first form or nothing |
33 | | - if( template.parameters[0] ) { |
| 33 | + if ( template.parameters[0] ) { |
34 | 34 | return template.parameters[0]; |
35 | 35 | } |
36 | 36 | return ''; |
— | — | @@ -41,10 +41,10 @@ |
42 | 42 | * @param {array} forms List of plural forms |
43 | 43 | * @return {string} Correct form for quantifier in this language |
44 | 44 | */ |
45 | | - 'convertPlural': function( count, forms ){ |
46 | | - if ( !forms || forms.length == 0 ) { |
| 45 | + 'convertPlural': function( count, forms ){ |
| 46 | + if ( !forms || forms.length == 0 ) { |
47 | 47 | return ''; |
48 | | - } |
| 48 | + } |
49 | 49 | return ( parseInt( count ) == 1 ) ? forms[0] : forms[1]; |
50 | 50 | }, |
51 | 51 | /** |
— | — | @@ -72,9 +72,9 @@ |
73 | 73 | } |
74 | 74 | // Set the target Transform table: |
75 | 75 | var transformTable = mediaWiki.language.digitTransformTable; |
76 | | - // Check if the "restore" to Latin number flag is set: |
77 | | - if ( integer ) { |
78 | | - if ( parseInt( number ) == number ) { |
| 76 | + // Check if the "restore" to Latin number flag is set: |
| 77 | + if ( integer ) { |
| 78 | + if ( parseInt( number ) == number ) { |
79 | 79 | return number; |
80 | 80 | } |
81 | 81 | var tmp = []; |
— | — | @@ -92,7 +92,7 @@ |
93 | 93 | convertedNumber += numberString[i]; |
94 | 94 | } |
95 | 95 | } |
96 | | - return integer ? parseInt( convertedNumber) : convertedNumber; |
| 96 | + return integer ? parseInt( convertedNumber ) : convertedNumber; |
97 | 97 | }, |
98 | 98 | // Digit Transform Table, populated by language classes where applicable |
99 | 99 | 'digitTransformTable': null |