r81402 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81401‎ | r81402 | r81403 >
Date:16:18, 2 February 2011
Author:catrope
Status:ok (Comments)
Tags:
Comment:
Modified paths:
  • /branches/REL1_17/phase3/config/index.php (modified) (history)
  • /branches/REL1_17/phase3/includes/AutoLoader.php (modified) (history)
  • /branches/REL1_17/phase3/includes/Collation.php (modified) (history)
  • /branches/REL1_17/phase3/includes/ImagePage.php (modified) (history)
  • /branches/REL1_17/phase3/includes/Title.php (modified) (history)
  • /branches/REL1_17/phase3/includes/User.php (modified) (history)
  • /branches/REL1_17/phase3/includes/installer/CliInstaller.php (modified) (history)
  • /branches/REL1_17/phase3/includes/installer/Installer.i18n.php (modified) (history)
  • /branches/REL1_17/phase3/includes/installer/Installer.php (modified) (history)
  • /branches/REL1_17/phase3/includes/installer/WebInstaller.php (modified) (history)
  • /branches/REL1_17/phase3/includes/media/GIF.php (modified) (history)
  • /branches/REL1_17/phase3/includes/media/Generic.php (modified) (history)
  • /branches/REL1_17/phase3/includes/media/PNG.php (modified) (history)
  • /branches/REL1_17/phase3/includes/parser/Parser.php (modified) (history)
  • /branches/REL1_17/phase3/includes/specials/SpecialSearch.php (modified) (history)
  • /branches/REL1_17/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /branches/REL1_17/phase3/maintenance/backupPrefetch.inc (modified) (history)
  • /branches/REL1_17/phase3/maintenance/dumpTextPass.php (modified) (history)
  • /branches/REL1_17/phase3/maintenance/install.php (modified) (history)
  • /branches/REL1_17/phase3/maintenance/language/messages.inc (modified) (history)
  • /branches/REL1_17/phase3/maintenance/minify.php (modified) (history)
  • /branches/REL1_17/phase3/maintenance/showStats.php (modified) (history)
  • /branches/REL1_17/phase3/resources/mediawiki.util/mediawiki.util.js (modified) (history)
  • /branches/REL1_17/phase3/resources/mediawiki/mediawiki.js (modified) (history)

Diff [purge]

Index: branches/REL1_17/phase3/maintenance/minify.php
@@ -17,6 +17,9 @@
1818 "Directory for output. If this is not specified, and neither is --outfile, then the\n" .
1919 "output files will be sent to the same directories as the input files.",
2020 false, true );
 21+ $this->addOption( 'minify-vertical-space',
 22+ "Boolean value for minifying the vertical space for javascript.",
 23+ false, true );
2124 $this->mDescription = "Minify a file or set of files.\n\n" .
2225 "If --outfile is not specified, then the output file names will have a .min extension\n" .
2326 "added, e.g. jquery.js -> jquery.min.js.";
@@ -78,6 +81,8 @@
7982 }
8083
8184 public function minify( $inPath, $outPath ) {
 85+ global $wgResourceLoaderMinifyJSVerticalSpace;
 86+
8287 $extension = $this->getExtension( $inPath );
8388 $this->output( basename( $inPath ) . ' -> ' . basename( $outPath ) . '...' );
8489
@@ -94,7 +99,7 @@
95100
96101 switch ( $extension ) {
97102 case 'js':
98 - $outText = JSMin::minify( $inText );
 103+ $outText = JavaScriptDistiller::stripWhiteSpace( $inText, $this->getOption( 'minify-vertical-space', $wgResourceLoaderMinifyJSVerticalSpace ) );
99104 break;
100105 case 'css':
101106 $outText = CSSMin::minify( $inText );
Index: branches/REL1_17/phase3/maintenance/install.php
@@ -20,7 +20,7 @@
2121 * @see wfWaitForSlaves()
2222 */
2323
24 -define( 'MW_CONFIG_CALLBACK', 'CoreInstaller::overrideConfig' );
 24+define( 'MW_CONFIG_CALLBACK', 'Installer::overrideConfig' );
2525
2626 require_once( dirname( dirname( __FILE__ ) )."/maintenance/Maintenance.php" );
2727
Index: branches/REL1_17/phase3/maintenance/language/messages.inc
@@ -1010,6 +1010,10 @@
10111011 'prefs-displaywatchlist',
10121012 'prefs-diffs',
10131013 ),
 1014+ 'preferences-email' => array(
 1015+ 'email-address-validity-valid',
 1016+ 'email-address-validity-invalid',
 1017+ ),
10141018 'userrights' => array(
10151019 'userrights',
10161020 'userrights-summary',
@@ -3296,6 +3300,7 @@
32973301 'opensearch' => 'OpenSearch description',
32983302 'quickbar' => 'Quickbar',
32993303 'preferences' => 'Preferences page',
 3304+ 'preferences-email' => 'User preference: e-mail validation using jQuery',
33003305 'userrights' => 'User rights',
33013306 'group' => 'Groups',
33023307 'group-member' => '',
Index: branches/REL1_17/phase3/maintenance/showStats.php
@@ -32,6 +32,7 @@
3333
3434 class ShowStats extends Maintenance {
3535 public function __construct() {
 36+ parent::__construct();
3637 $this->mDescription = "Show the cached statistics";
3738 }
3839 public function execute() {
Index: branches/REL1_17/phase3/maintenance/dumpTextPass.php
@@ -95,18 +95,28 @@
9696 }
9797
9898 function processFileOpt( $val, $param ) {
99 - switch( $val ) {
100 - case "file":
101 - return $param;
102 - case "gzip":
103 - return "compress.zlib://$param";
104 - case "bzip2":
105 - return "compress.bzip2://$param";
106 - case "7zip":
107 - return "mediawiki.compress.7z://$param";
108 - default:
109 - return $val;
 99+ $fileURIs = explode(';',$param);
 100+ foreach ( $fileURIs as $URI ) {
 101+ switch( $val ) {
 102+ case "file":
 103+ $newURI = $URI;
 104+ break;
 105+ case "gzip":
 106+ $newURI = "compress.zlib://$URI";
 107+ break;
 108+ case "bzip2":
 109+ $newURI = "compress.bzip2://$URI";
 110+ break;
 111+ case "7zip":
 112+ $newURI = "mediawiki.compress.7z://$URI";
 113+ break;
 114+ default:
 115+ $newURI = $URI;
 116+ }
 117+ $newFileURIs[] = $newURI;
110118 }
 119+ $val = implode( ';', $newFileURIs );
 120+ return $val;
111121 }
112122
113123 /**
Index: branches/REL1_17/phase3/maintenance/backupPrefetch.inc
@@ -27,9 +27,12 @@
2828 var $atPageEnd = false;
2929 var $lastPage = 0;
3030 var $lastRev = 0;
 31+ var $infiles = null;
3132
3233 function BaseDump( $infile ) {
 34+ $this->infiles = explode(';',$infile);
3335 $this->reader = new XMLReader();
 36+ $infile = array_shift($this->infiles);
3437 $this->reader->open( $infile );
3538 }
3639
@@ -83,7 +86,12 @@
8487 $this->atPageEnd = false;
8588 }
8689 } else {
87 - $this->atEnd = true;
 90+ $this->close();
 91+ if (count($this->infiles)) {
 92+ $infile = array_shift($this->infiles);
 93+ $this->reader->open( $infile );
 94+ $this->atEnd = false;
 95+ }
8896 }
8997 }
9098
Index: branches/REL1_17/phase3/includes/User.php
@@ -666,9 +666,13 @@
667667 if( !wfRunHooks( 'isValidEmailAddr', array( $addr, &$result ) ) ) {
668668 return $result;
669669 }
670 - $rfc5322_atext = "a-z0-9!#$%&'*+-\/=?^_`{|}~" ;
671 - $rfc1034_ldh_str = "a-z0-9-" ;
672670
 671+ // Please note strings below are enclosed in brackets [], this make the
 672+ // hyphen "-" a range indicator. Hence it is double backslashed below.
 673+ // See bug 26948
 674+ $rfc5322_atext = "a-z0-9!#$%&'*+\\-\/=?^_`{|}~" ;
 675+ $rfc1034_ldh_str = "a-z0-9\\-" ;
 676+
673677 $HTML5_email_regexp = "/
674678 ^ # start of string
675679 [$rfc5322_atext\\.]+ # user part which is liberal :p
Index: branches/REL1_17/phase3/includes/parser/Parser.php
@@ -444,7 +444,7 @@
445445 * Expand templates and variables in the text, producing valid, static wikitext.
446446 * Also removes comments.
447447 */
448 - function preprocess( $text, $title, $options, $revid = null ) {
 448+ function preprocess( $text, Title $title, ParserOptions $options, $revid = null ) {
449449 wfProfileIn( __METHOD__ );
450450 $this->mOptions = $options;
451451 $this->clearState();
@@ -467,7 +467,7 @@
468468 * <noinclude>, <includeonly> etc. are parsed as for template transclusion,
469469 * comments, templates, arguments, tags hooks and parser functions are untouched.
470470 */
471 - public function getPreloadText( $text, $title, $options ) {
 471+ public function getPreloadText( $text, Title $title, ParserOptions $options ) {
472472 # Parser (re)initialisation
473473 $this->mOptions = $options;
474474 $this->clearState();
@@ -4205,7 +4205,7 @@
42064206 * Set up some variables which are usually set up in parse()
42074207 * so that an external function can call some class members with confidence
42084208 */
4209 - public function startExternalParse( &$title, $options, $outputType, $clearState = true ) {
 4209+ public function startExternalParse( Title $title = null, ParserOptions $options, $outputType, $clearState = true ) {
42104210 $this->setTitle( $title );
42114211 $this->mOptions = $options;
42124212 $this->setOutputType( $outputType );
@@ -4232,7 +4232,13 @@
42334233 $executing = true;
42344234
42354235 wfProfileIn( __METHOD__ );
4236 - $text = $this->preprocess( $text, $wgTitle, $options );
 4236+ $title = $wgTitle;
 4237+ if ( !$title ) {
 4238+ # It's not uncommon having a null $wgTitle in scripts. See r80898
 4239+ # Create a ghost title in such case
 4240+ $title = Title::newFromText( 'Dwimmerlaik' );
 4241+ }
 4242+ $text = $this->preprocess( $text, $title, $options );
42374243
42384244 $executing = false;
42394245 wfProfileOut( __METHOD__ );
@@ -5074,7 +5080,7 @@
50755081 /**
50765082 * strip/replaceVariables/unstrip for preprocessor regression testing
50775083 */
5078 - function testSrvus( $text, $title, $options, $outputType = self::OT_HTML ) {
 5084+ function testSrvus( $text, $title, ParserOptions $options, $outputType = self::OT_HTML ) {
50795085 $this->mOptions = $options;
50805086 $this->clearState();
50815087 if ( !$title instanceof Title ) {
Property changes on: branches/REL1_17/phase3/includes/parser/Parser.php
___________________________________________________________________
Modified: svn:mergeinfo
50825088 Merged /trunk/phase3/includes/parser/Parser.php:r79915,79957,79964,79990,80687,80999,81006,81011,81101,81105,81138,81141,81146,81149-81150,81166,81171
Index: branches/REL1_17/phase3/includes/ImagePage.php
@@ -330,7 +330,7 @@
331331 $height_orig = $this->displayImg->getHeight( $page );
332332 $height = $height_orig;
333333
334 - $longDesc = $this->displayImg->getLongDesc();
 334+ $longDesc = wfMsgExt( 'parentheses', 'parseinline', $this->displayImg->getLongDesc() );
335335
336336 wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this, &$wgOut ) );
337337
Index: branches/REL1_17/phase3/includes/installer/WebInstaller.php
@@ -12,7 +12,7 @@
1313 * @ingroup Deployment
1414 * @since 1.17
1515 */
16 -class WebInstaller extends CoreInstaller {
 16+class WebInstaller extends Installer {
1717
1818 /**
1919 * @var WebInstallerOutput
Index: branches/REL1_17/phase3/includes/installer/Installer.php
@@ -104,7 +104,184 @@
105105 'envCheckLibicu'
106106 );
107107
 108+ /**
 109+ * MediaWiki configuration globals that will eventually be passed through
 110+ * to LocalSettings.php. The names only are given here, the defaults
 111+ * typically come from DefaultSettings.php.
 112+ *
 113+ * @var array
 114+ */
 115+ protected $defaultVarNames = array(
 116+ 'wgSitename',
 117+ 'wgPasswordSender',
 118+ 'wgLanguageCode',
 119+ 'wgRightsIcon',
 120+ 'wgRightsText',
 121+ 'wgRightsUrl',
 122+ 'wgMainCacheType',
 123+ 'wgEnableEmail',
 124+ 'wgEnableUserEmail',
 125+ 'wgEnotifUserTalk',
 126+ 'wgEnotifWatchlist',
 127+ 'wgEmailAuthentication',
 128+ 'wgDBtype',
 129+ 'wgDiff3',
 130+ 'wgImageMagickConvertCommand',
 131+ 'IP',
 132+ 'wgScriptPath',
 133+ 'wgScriptExtension',
 134+ 'wgMetaNamespace',
 135+ 'wgDeletedDirectory',
 136+ 'wgEnableUploads',
 137+ 'wgLogo',
 138+ 'wgShellLocale',
 139+ 'wgSecretKey',
 140+ 'wgUseInstantCommons',
 141+ 'wgUpgradeKey',
 142+ 'wgDefaultSkin',
 143+ );
 144+
108145 /**
 146+ * Variables that are stored alongside globals, and are used for any
 147+ * configuration of the installation process aside from the MediaWiki
 148+ * configuration. Map of names to defaults.
 149+ *
 150+ * @var array
 151+ */
 152+ protected $internalDefaults = array(
 153+ '_UserLang' => 'en',
 154+ '_Environment' => false,
 155+ '_CompiledDBs' => array(),
 156+ '_SafeMode' => false,
 157+ '_RaiseMemory' => false,
 158+ '_UpgradeDone' => false,
 159+ '_InstallDone' => false,
 160+ '_Caches' => array(),
 161+ '_InstallUser' => 'root',
 162+ '_InstallPassword' => '',
 163+ '_SameAccount' => true,
 164+ '_CreateDBAccount' => false,
 165+ '_NamespaceType' => 'site-name',
 166+ '_AdminName' => '', // will be set later, when the user selects language
 167+ '_AdminPassword' => '',
 168+ '_AdminPassword2' => '',
 169+ '_AdminEmail' => '',
 170+ '_Subscribe' => false,
 171+ '_SkipOptional' => 'continue',
 172+ '_RightsProfile' => 'wiki',
 173+ '_LicenseCode' => 'none',
 174+ '_CCDone' => false,
 175+ '_Extensions' => array(),
 176+ '_MemCachedServers' => '',
 177+ '_UpgradeKeySupplied' => false,
 178+ '_ExistingDBSettings' => false,
 179+ );
 180+
 181+ /**
 182+ * The actual list of installation steps. This will be initialized by getInstallSteps()
 183+ *
 184+ * @var array
 185+ */
 186+ private $installSteps = array();
 187+
 188+ /**
 189+ * Extra steps for installation, for things like DatabaseInstallers to modify
 190+ *
 191+ * @var array
 192+ */
 193+ protected $extraInstallSteps = array();
 194+
 195+ /**
 196+ * Known object cache types and the functions used to test for their existence.
 197+ *
 198+ * @var array
 199+ */
 200+ protected $objectCaches = array(
 201+ 'xcache' => 'xcache_get',
 202+ 'apc' => 'apc_fetch',
 203+ 'eaccel' => 'eaccelerator_get',
 204+ 'wincache' => 'wincache_ucache_get'
 205+ );
 206+
 207+ /**
 208+ * User rights profiles.
 209+ *
 210+ * @var array
 211+ */
 212+ public $rightsProfiles = array(
 213+ 'wiki' => array(),
 214+ 'no-anon' => array(
 215+ '*' => array( 'edit' => false )
 216+ ),
 217+ 'fishbowl' => array(
 218+ '*' => array(
 219+ 'createaccount' => false,
 220+ 'edit' => false,
 221+ ),
 222+ ),
 223+ 'private' => array(
 224+ '*' => array(
 225+ 'createaccount' => false,
 226+ 'edit' => false,
 227+ 'read' => false,
 228+ ),
 229+ ),
 230+ );
 231+
 232+ /**
 233+ * License types.
 234+ *
 235+ * @var array
 236+ */
 237+ public $licenses = array(
 238+ 'cc-by-sa' => array(
 239+ 'url' => 'http://creativecommons.org/licenses/by-sa/3.0/',
 240+ 'icon' => '{$wgStylePath}/common/images/cc-by-sa.png',
 241+ ),
 242+ 'cc-by-nc-sa' => array(
 243+ 'url' => 'http://creativecommons.org/licenses/by-nc-sa/3.0/',
 244+ 'icon' => '{$wgStylePath}/common/images/cc-by-nc-sa.png',
 245+ ),
 246+ 'pd' => array(
 247+ 'url' => 'http://creativecommons.org/licenses/publicdomain/',
 248+ 'icon' => '{$wgStylePath}/common/images/public-domain.png',
 249+ ),
 250+ 'gfdl-old' => array(
 251+ 'url' => 'http://www.gnu.org/licenses/old-licenses/fdl-1.2.html',
 252+ 'icon' => '{$wgStylePath}/common/images/gnu-fdl.png',
 253+ ),
 254+ 'gfdl-current' => array(
 255+ 'url' => 'http://www.gnu.org/copyleft/fdl.html',
 256+ 'icon' => '{$wgStylePath}/common/images/gnu-fdl.png',
 257+ ),
 258+ 'none' => array(
 259+ 'url' => '',
 260+ 'icon' => '',
 261+ 'text' => ''
 262+ ),
 263+ 'cc-choose' => array(
 264+ // Details will be filled in by the selector.
 265+ 'url' => '',
 266+ 'icon' => '',
 267+ 'text' => '',
 268+ ),
 269+ );
 270+
 271+ /**
 272+ * URL to mediawiki-announce subscription
 273+ */
 274+ protected $mediaWikiAnnounceUrl = 'https://lists.wikimedia.org/mailman/subscribe/mediawiki-announce';
 275+
 276+ /**
 277+ * Supported language codes for Mailman
 278+ */
 279+ protected $mediaWikiAnnounceLanguages = array(
 280+ 'ca', 'cs', 'da', 'de', 'en', 'es', 'et', 'eu', 'fi', 'fr', 'hr', 'hu',
 281+ 'it', 'ja', 'ko', 'lt', 'nl', 'no', 'pl', 'pt', 'pt-br', 'ro', 'ru',
 282+ 'sl', 'sr', 'sv', 'tr', 'uk'
 283+ );
 284+
 285+ /**
109286 * UI interface for displaying a short message
110287 * The parameters are like parameters to wfMsg().
111288 * The messages will be in wikitext format, which will be converted to an
@@ -113,12 +290,58 @@
114291 public abstract function showMessage( $msg /*, ... */ );
115292
116293 /**
 294+ * Show a message to the installing user by using a Status object
 295+ * @param $status Status
 296+ */
 297+ public abstract function showStatusMessage( Status $status );
 298+
 299+ /**
117300 * Constructor, always call this from child classes.
118301 */
119302 public function __construct() {
 303+ global $wgExtensionMessagesFiles, $wgUser, $wgHooks;
 304+
120305 // Disable the i18n cache and LoadBalancer
121306 Language::getLocalisationCache()->disableBackend();
122307 LBFactory::disableBackend();
 308+
 309+ // Load the installer's i18n file.
 310+ $wgExtensionMessagesFiles['MediawikiInstaller'] =
 311+ dirname( __FILE__ ) . '/Installer.i18n.php';
 312+
 313+ // Having a user with id = 0 safeguards us from DB access via User::loadOptions().
 314+ $wgUser = User::newFromId( 0 );
 315+
 316+ // Set our custom <doclink> hook.
 317+ $wgHooks['ParserFirstCallInit'][] = array( $this, 'registerDocLink' );
 318+
 319+ $this->settings = $this->internalDefaults;
 320+
 321+ foreach ( $this->defaultVarNames as $var ) {
 322+ $this->settings[$var] = $GLOBALS[$var];
 323+ }
 324+
 325+ foreach ( self::getDBTypes() as $type ) {
 326+ $installer = $this->getDBInstaller( $type );
 327+
 328+ if ( !$installer->isCompiled() ) {
 329+ continue;
 330+ }
 331+
 332+ $defaults = $installer->getGlobalDefaults();
 333+
 334+ foreach ( $installer->getGlobalNames() as $var ) {
 335+ if ( isset( $defaults[$var] ) ) {
 336+ $this->settings[$var] = $defaults[$var];
 337+ } else {
 338+ $this->settings[$var] = $GLOBALS[$var];
 339+ }
 340+ }
 341+ }
 342+
 343+ $this->parserTitle = Title::newFromText( 'Installer' );
 344+ $this->parserOptions = new ParserOptions; // language will be wrong :(
 345+ $this->parserOptions->setEditSection( false );
123346 }
124347
125348 /**
@@ -521,12 +744,8 @@
522745 return true;
523746 }
524747
525 - $n = intval( $limit );
 748+ $n = wfShorthandToInteger( $limit );
526749
527 - if( preg_match( '/^([0-9]+)[Mm]$/', trim( $limit ), $m ) ) {
528 - $n = intval( $m[1] * ( 1024 * 1024 ) );
529 - }
530 -
531750 if( $n < $this->minMemorySize * 1024 * 1024 ) {
532751 $newLimit = "{$this->minMemorySize}M";
533752
@@ -907,4 +1126,347 @@
9081127 return false;
9091128 }
9101129
 1130+ /**
 1131+ * Register tag hook below.
 1132+ *
 1133+ * @todo Move this to WebInstaller with the two things below?
 1134+ *
 1135+ * @param $parser Parser
 1136+ */
 1137+ public function registerDocLink( Parser &$parser ) {
 1138+ $parser->setHook( 'doclink', array( $this, 'docLink' ) );
 1139+ return true;
 1140+ }
 1141+
 1142+ /**
 1143+ * ParserOptions are constructed before we determined the language, so fix it
 1144+ */
 1145+ public function setParserLanguage( $lang ) {
 1146+ $this->parserOptions->setTargetLanguage( $lang );
 1147+ $this->parserOptions->setUserLang( $lang->getCode() );
 1148+ }
 1149+
 1150+ /**
 1151+ * Extension tag hook for a documentation link.
 1152+ */
 1153+ public function docLink( $linkText, $attribs, $parser ) {
 1154+ $url = $this->getDocUrl( $attribs['href'] );
 1155+ return '<a href="' . htmlspecialchars( $url ) . '">' .
 1156+ htmlspecialchars( $linkText ) .
 1157+ '</a>';
 1158+ }
 1159+
 1160+ /**
 1161+ * Overridden by WebInstaller to provide lastPage parameters.
 1162+ */
 1163+ protected function getDocUrl( $page ) {
 1164+ return "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
 1165+ }
 1166+
 1167+ /**
 1168+ * Finds extensions that follow the format /extensions/Name/Name.php,
 1169+ * and returns an array containing the value for 'Name' for each found extension.
 1170+ *
 1171+ * @return array
 1172+ */
 1173+ public function findExtensions() {
 1174+ if( $this->getVar( 'IP' ) === null ) {
 1175+ return false;
 1176+ }
 1177+
 1178+ $exts = array();
 1179+ $dir = $this->getVar( 'IP' ) . '/extensions';
 1180+ $dh = opendir( $dir );
 1181+
 1182+ while ( ( $file = readdir( $dh ) ) !== false ) {
 1183+ if( file_exists( "$dir/$file/$file.php" ) ) {
 1184+ $exts[] = $file;
 1185+ }
 1186+ }
 1187+
 1188+ return $exts;
 1189+ }
 1190+
 1191+ /**
 1192+ * Installs the auto-detected extensions.
 1193+ *
 1194+ * @return Status
 1195+ */
 1196+ protected function includeExtensions() {
 1197+ $exts = $this->getVar( '_Extensions' );
 1198+ $path = $this->getVar( 'IP' ) . '/extensions';
 1199+
 1200+ foreach( $exts as $e ) {
 1201+ require( "$path/$e/$e.php" );
 1202+ }
 1203+
 1204+ return Status::newGood();
 1205+ }
 1206+
 1207+ /**
 1208+ * Get an array of install steps. Should always be in the format of
 1209+ * array(
 1210+ * 'name' => 'someuniquename',
 1211+ * 'callback' => array( $obj, 'method' ),
 1212+ * )
 1213+ * There must be a config-install-$name message defined per step, which will
 1214+ * be shown on install.
 1215+ *
 1216+ * @param $installer DatabaseInstaller so we can make callbacks
 1217+ * @return array
 1218+ */
 1219+ protected function getInstallSteps( DatabaseInstaller &$installer ) {
 1220+ $coreInstallSteps = array(
 1221+ array( 'name' => 'database', 'callback' => array( $installer, 'setupDatabase' ) ),
 1222+ array( 'name' => 'tables', 'callback' => array( $this, 'installTables' ) ),
 1223+ array( 'name' => 'interwiki', 'callback' => array( $installer, 'populateInterwikiTable' ) ),
 1224+ array( 'name' => 'secretkey', 'callback' => array( $this, 'generateSecretKey' ) ),
 1225+ array( 'name' => 'upgradekey', 'callback' => array( $this, 'generateUpgradeKey' ) ),
 1226+ array( 'name' => 'sysop', 'callback' => array( $this, 'createSysop' ) ),
 1227+ array( 'name' => 'mainpage', 'callback' => array( $this, 'createMainpage' ) ),
 1228+ );
 1229+
 1230+ // Build the array of install steps starting from the core install list,
 1231+ // then adding any callbacks that wanted to attach after a given step
 1232+ foreach( $coreInstallSteps as $step ) {
 1233+ $this->installSteps[] = $step;
 1234+ if( isset( $this->extraInstallSteps[ $step['name'] ] ) ) {
 1235+ $this->installSteps = array_merge(
 1236+ $this->installSteps,
 1237+ $this->extraInstallSteps[ $step['name'] ]
 1238+ );
 1239+ }
 1240+ }
 1241+
 1242+ // Prepend any steps that want to be at the beginning
 1243+ if( isset( $this->extraInstallSteps['BEGINNING'] ) ) {
 1244+ $this->installSteps = array_merge(
 1245+ $this->extraInstallSteps['BEGINNING'],
 1246+ $this->installSteps
 1247+ );
 1248+ }
 1249+
 1250+ // Extensions should always go first, chance to tie into hooks and such
 1251+ if( count( $this->getVar( '_Extensions' ) ) ) {
 1252+ array_unshift( $this->installSteps,
 1253+ array( 'name' => 'extensions', 'callback' => array( $this, 'includeExtensions' ) )
 1254+ );
 1255+ }
 1256+ return $this->installSteps;
 1257+ }
 1258+
 1259+ /**
 1260+ * Actually perform the installation.
 1261+ *
 1262+ * @param $startCB A callback array for the beginning of each step
 1263+ * @param $endCB A callback array for the end of each step
 1264+ *
 1265+ * @return Array of Status objects
 1266+ */
 1267+ public function performInstallation( $startCB, $endCB ) {
 1268+ $installResults = array();
 1269+ $installer = $this->getDBInstaller();
 1270+ $installer->preInstall();
 1271+ $steps = $this->getInstallSteps( $installer );
 1272+ foreach( $steps as $stepObj ) {
 1273+ $name = $stepObj['name'];
 1274+ call_user_func_array( $startCB, array( $name ) );
 1275+
 1276+ // Perform the callback step
 1277+ $status = call_user_func_array( $stepObj['callback'], array( &$installer ) );
 1278+
 1279+ // Output and save the results
 1280+ call_user_func_array( $endCB, array( $name, $status ) );
 1281+ $installResults[$name] = $status;
 1282+
 1283+ // If we've hit some sort of fatal, we need to bail.
 1284+ // Callback already had a chance to do output above.
 1285+ if( !$status->isOk() ) {
 1286+ break;
 1287+ }
 1288+ }
 1289+ if( $status->isOk() ) {
 1290+ $this->setVar( '_InstallDone', true );
 1291+ }
 1292+ return $installResults;
 1293+ }
 1294+
 1295+ /**
 1296+ * Generate $wgSecretKey. Will warn if we had to use mt_rand() instead of
 1297+ * /dev/urandom
 1298+ *
 1299+ * @return Status
 1300+ */
 1301+ protected function generateSecretKey() {
 1302+ return $this->generateSecret( 'wgSecretKey' );
 1303+ }
 1304+
 1305+ /**
 1306+ * Generate a secret value for a variable using either
 1307+ * /dev/urandom or mt_rand() Produce a warning in the later case.
 1308+ *
 1309+ * @return Status
 1310+ */
 1311+ protected function generateSecret( $secretName, $length = 64 ) {
 1312+ if ( wfIsWindows() ) {
 1313+ $file = null;
 1314+ } else {
 1315+ wfSuppressWarnings();
 1316+ $file = fopen( "/dev/urandom", "r" );
 1317+ wfRestoreWarnings();
 1318+ }
 1319+
 1320+ $status = Status::newGood();
 1321+
 1322+ if ( $file ) {
 1323+ $secretKey = bin2hex( fread( $file, $length / 2 ) );
 1324+ fclose( $file );
 1325+ } else {
 1326+ $secretKey = '';
 1327+
 1328+ for ( $i = 0; $i < $length / 8; $i++ ) {
 1329+ $secretKey .= dechex( mt_rand( 0, 0x7fffffff ) );
 1330+ }
 1331+
 1332+ $status->warning( 'config-insecure-secret', '$' . $secretName );
 1333+ }
 1334+
 1335+ $this->setVar( $secretName, $secretKey );
 1336+
 1337+ return $status;
 1338+ }
 1339+
 1340+ /**
 1341+ * Generate a default $wgUpgradeKey. Will warn if we had to use
 1342+ * mt_rand() instead of /dev/urandom
 1343+ *
 1344+ * @return Status
 1345+ */
 1346+ public function generateUpgradeKey() {
 1347+ if ( strval( $this->getVar( 'wgUpgradeKey' ) ) === '' ) {
 1348+ return $this->generateSecret( 'wgUpgradeKey', 16 );
 1349+ }
 1350+ return Status::newGood();
 1351+ }
 1352+
 1353+ /**
 1354+ * Create the first user account, grant it sysop and bureaucrat rights
 1355+ *
 1356+ * @return Status
 1357+ */
 1358+ protected function createSysop() {
 1359+ $name = $this->getVar( '_AdminName' );
 1360+ $user = User::newFromName( $name );
 1361+
 1362+ if ( !$user ) {
 1363+ // We should've validated this earlier anyway!
 1364+ return Status::newFatal( 'config-admin-error-user', $name );
 1365+ }
 1366+
 1367+ if ( $user->idForName() == 0 ) {
 1368+ $user->addToDatabase();
 1369+
 1370+ try {
 1371+ $user->setPassword( $this->getVar( '_AdminPassword' ) );
 1372+ } catch( PasswordError $pwe ) {
 1373+ return Status::newFatal( 'config-admin-error-password', $name, $pwe->getMessage() );
 1374+ }
 1375+
 1376+ $user->addGroup( 'sysop' );
 1377+ $user->addGroup( 'bureaucrat' );
 1378+ if( $this->getVar( '_AdminEmail' ) ) {
 1379+ $user->setEmail( $this->getVar( '_AdminEmail' ) );
 1380+ }
 1381+ $user->saveSettings();
 1382+ }
 1383+ $status = Status::newGood();
 1384+
 1385+ if( $this->getVar( '_Subscribe' ) && $this->getVar( '_AdminEmail' ) ) {
 1386+ $this->subscribeToMediaWikiAnnounce( $status );
 1387+ }
 1388+
 1389+ return $status;
 1390+ }
 1391+
 1392+ private function subscribeToMediaWikiAnnounce( Status $s ) {
 1393+ $params = array(
 1394+ 'email' => $this->getVar( '_AdminEmail' ),
 1395+ 'language' => 'en',
 1396+ 'digest' => 0
 1397+ );
 1398+
 1399+ // Mailman doesn't support as many languages as we do, so check to make
 1400+ // sure their selected language is available
 1401+ $myLang = $this->getVar( '_UserLang' );
 1402+ if( in_array( $myLang, $this->mediaWikiAnnounceLanguages ) ) {
 1403+ $myLang = $myLang == 'pt-br' ? 'pt_BR' : $myLang; // rewrite to Mailman's pt_BR
 1404+ $params['language'] = $myLang;
 1405+ }
 1406+
 1407+ $res = Http::post( $this->mediaWikiAnnounceUrl, array( 'postData' => $params ) );
 1408+ if( !$res ) {
 1409+ $s->warning( 'config-install-subscribe-fail' );
 1410+ }
 1411+ }
 1412+
 1413+ /**
 1414+ * Insert Main Page with default content.
 1415+ *
 1416+ * @return Status
 1417+ */
 1418+ protected function createMainpage( DatabaseInstaller &$installer ) {
 1419+ $status = Status::newGood();
 1420+ try {
 1421+ $article = new Article( Title::newMainPage() );
 1422+ $article->doEdit( wfMsgForContent( 'mainpagetext' ) . "\n\n" .
 1423+ wfMsgForContent( 'mainpagedocfooter' ),
 1424+ '',
 1425+ EDIT_NEW,
 1426+ false,
 1427+ User::newFromName( 'MediaWiki Default' ) );
 1428+ } catch (MWException $e) {
 1429+ //using raw, because $wgShowExceptionDetails can not be set yet
 1430+ $status->fatal( 'config-install-mainpage-failed', $e->getMessage() );
 1431+ }
 1432+
 1433+ return $status;
 1434+ }
 1435+
 1436+ /**
 1437+ * Override the necessary bits of the config to run an installation.
 1438+ */
 1439+ public static function overrideConfig() {
 1440+ define( 'MW_NO_SESSION', 1 );
 1441+
 1442+ // Don't access the database
 1443+ $GLOBALS['wgUseDatabaseMessages'] = false;
 1444+ // Debug-friendly
 1445+ $GLOBALS['wgShowExceptionDetails'] = true;
 1446+ // Don't break forms
 1447+ $GLOBALS['wgExternalLinkTarget'] = '_blank';
 1448+
 1449+ // Extended debugging
 1450+ $GLOBALS['wgShowSQLErrors'] = true;
 1451+ $GLOBALS['wgShowDBErrorBacktrace'] = true;
 1452+
 1453+ // Allow multiple ob_flush() calls
 1454+ $GLOBALS['wgDisableOutputCompression'] = true;
 1455+
 1456+ // Use a sensible cookie prefix (not my_wiki)
 1457+ $GLOBALS['wgCookiePrefix'] = 'mw_installer';
 1458+
 1459+ // Some of the environment checks make shell requests, remove limits
 1460+ $GLOBALS['wgMaxShellMemory'] = 0;
 1461+ }
 1462+
 1463+ /**
 1464+ * Add an installation step following the given step.
 1465+ *
 1466+ * @param $callback Array A valid installation callback array, in this form:
 1467+ * array( 'name' => 'some-unique-name', 'callback' => array( $obj, 'function' ) );
 1468+ * @param $findStep String the step to find. Omit to put the step at the beginning
 1469+ */
 1470+ public function addInstallStep( $callback, $findStep = 'BEGINNING' ) {
 1471+ $this->extraInstallSteps[$findStep][] = $callback;
 1472+ }
9111473 }
Index: branches/REL1_17/phase3/includes/installer/Installer.i18n.php
@@ -372,7 +372,7 @@
373373 More complex user rights configurations are available after installation, see the [http://www.mediawiki.org/wiki/Manual:User_rights relevant manual entry].",
374374 'config-license' => 'Copyright and license:',
375375 'config-license-none' => 'No license footer',
376 - 'config-license-cc-by-sa' => 'Creative Commons Attribution Share Alike (Wikipedia-compatible)',
 376+ 'config-license-cc-by-sa' => 'Creative Commons Attribution Share Alike',
377377 'config-license-cc-by-nc-sa' => 'Creative Commons Attribution Non-Commercial Share Alike',
378378 'config-license-gfdl-old' => 'GNU Free Documentation License 1.2',
379379 'config-license-gfdl-current' => 'GNU Free Documentation License 1.3 or later',
Index: branches/REL1_17/phase3/includes/installer/CliInstaller.php
@@ -12,7 +12,7 @@
1313 * @ingroup Deployment
1414 * @since 1.17
1515 */
16 -class CliInstaller extends CoreInstaller {
 16+class CliInstaller extends Installer {
1717
1818 private $optionMap = array(
1919 'dbtype' => 'wgDBtype',
Index: branches/REL1_17/phase3/includes/media/Generic.php
@@ -240,8 +240,8 @@
241241
242242 function getShortDesc( $file ) {
243243 global $wgLang;
244 - $nbytes = '(' . wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ),
245 - $wgLang->formatNum( $file->getSize() ) ) . ')';
 244+ $nbytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ),
 245+ $wgLang->formatNum( $file->getSize() ) );
246246 return "$nbytes";
247247 }
248248
@@ -255,8 +255,8 @@
256256
257257 static function getGeneralShortDesc( $file ) {
258258 global $wgLang;
259 - $nbytes = '(' . wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ),
260 - $wgLang->formatNum( $file->getSize() ) ) . ')';
 259+ $nbytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ),
 260+ $wgLang->formatNum( $file->getSize() ) );
261261 return "$nbytes";
262262 }
263263
Index: branches/REL1_17/phase3/includes/media/PNG.php
@@ -63,7 +63,7 @@
6464 return $original;
6565
6666 $info = array();
67 - $info[] = substr( $original, 1, strlen( $original )-2 );
 67+ $info[] = $original;
6868
6969 if ($metadata['loopCount'] == 0)
7070 $info[] = wfMsgExt( 'file-info-png-looped', 'parseinline' );
@@ -76,9 +76,7 @@
7777 if ($metadata['duration'])
7878 $info[] = $wgLang->formatTimePeriod( $metadata['duration'] );
7979
80 - $infoString = $wgLang->commaList( $info );
81 -
82 - return "($infoString)";
 80+ return $wgLang->commaList( $info );
8381 }
8482
8583 }
Index: branches/REL1_17/phase3/includes/media/GIF.php
@@ -75,7 +75,7 @@
7676 return $original;
7777
7878 $info = array();
79 - $info[] = substr( $original, 1, strlen( $original )-2 );
 79+ $info[] = $original;
8080
8181 if ($metadata['looped'])
8282 $info[] = wfMsgExt( 'file-info-gif-looped', 'parseinline' );
@@ -86,8 +86,6 @@
8787 if ($metadata['duration'])
8888 $info[] = $wgLang->formatTimePeriod( $metadata['duration'] );
8989
90 - $infoString = $wgLang->commaList( $info );
91 -
92 - return "($infoString)";
 90+ return $wgLang->commaList( $info );
9391 }
9492 }
Index: branches/REL1_17/phase3/includes/AutoLoader.php
@@ -444,7 +444,6 @@
445445 # includes/installer
446446 'CliInstaller' => 'includes/installer/CliInstaller.php',
447447 'Installer' => 'includes/installer/Installer.php',
448 - 'CoreInstaller' => 'includes/installer/CoreInstaller.php',
449448 'DatabaseInstaller' => 'includes/installer/DatabaseInstaller.php',
450449 'DatabaseUpdater' => 'includes/installer/DatabaseUpdater.php',
451450 'LBFactory_InstallerFake' => 'includes/installer/Installer.php',
Property changes on: branches/REL1_17/phase3/includes/AutoLoader.php
___________________________________________________________________
Modified: svn:mergeinfo
452451 Merged /trunk/phase3/includes/AutoLoader.php:r79915,79957,79964,79990,80687,80999,81006,81011,81101,81105,81138,81141,81146,81149-81150,81166,81171
Index: branches/REL1_17/phase3/includes/Title.php
@@ -4211,9 +4211,10 @@
42124212 public function getCategorySortkey( $prefix = '' ) {
42134213 $unprefixed = $this->getText();
42144214 if ( $prefix !== '' ) {
4215 - # Separate with a null byte, so the unprefixed part is only used as
4216 - # a tiebreaker when two pages have the exact same prefix -- null
4217 - # sorts before everything else (hopefully).
 4215+ # Separate with a line feed, so the unprefixed part is only used as
 4216+ # a tiebreaker when two pages have the exact same prefix.
 4217+ # In UCA, tab is the only character that can sort above LF
 4218+ # so we strip both of them from the original prefix.
42184219 $prefix = strtr( $prefix, "\n\t", ' ' );
42194220 return "$prefix\n$unprefixed";
42204221 }
Property changes on: branches/REL1_17/phase3/includes/Title.php
___________________________________________________________________
Modified: svn:mergeinfo
42214222 Merged /trunk/phase3/includes/Title.php:r79915,79957,79964,79990,80687,80999,81006,81011,81101,81105,81138,81141,81146,81149-81150,81166,81171
Index: branches/REL1_17/phase3/includes/Collation.php
@@ -26,7 +26,7 @@
2727 * Given a string, convert it to a (hopefully short) key that can be used
2828 * for efficient sorting. A binary sort according to the sortkeys
2929 * corresponds to a logical sort of the corresponding strings. Current
30 - * code expects that a null character should sort before all others, but
 30+ * code expects that a line feed character should sort before all others, but
3131 * has no other particular expectations (and that one can be changed if
3232 * necessary).
3333 *
@@ -130,6 +130,9 @@
131131 }
132132
133133 function getSortKey( $string ) {
 134+ // intl extension produces non null-terminated
 135+ // strings. Appending '' fixes it so that it doesn't generate
 136+ // a warning on each access in debug php.
134137 wfSuppressWarnings();
135138 $key = $this->mainCollator->getSortKey( $string ) . '';
136139 wfRestoreWarnings();
Index: branches/REL1_17/phase3/includes/specials/SpecialSearch.php
@@ -587,7 +587,7 @@
588588 if( $img ) {
589589 $thumb = $img->transform( array( 'width' => 120, 'height' => 120 ) );
590590 if( $thumb ) {
591 - $desc = $img->getShortDesc();
 591+ $desc = wfMsgExt( 'parentheses', 'parseinline', $img->getShortDesc() );
592592 wfProfileOut( __METHOD__ );
593593 // Float doesn't seem to interact well with the bullets.
594594 // Table messes up vertical alignment of the bullets.
Property changes on: branches/REL1_17/phase3/includes/specials/SpecialSearch.php
___________________________________________________________________
Modified: svn:mergeinfo
595595 Merged /trunk/phase3/includes/specials/SpecialSearch.php:r79915,79957,79964,79990,80687,80999,81006,81011,81101,81105,81138,81141,81146,81149-81150,81166,81171
Index: branches/REL1_17/phase3/config/index.php
@@ -5,7 +5,7 @@
66 * @file
77 */
88
9 -define( 'MW_CONFIG_CALLBACK', 'CoreInstaller::overrideConfig' );
 9+define( 'MW_CONFIG_CALLBACK', 'Installer::overrideConfig' );
1010 define( 'MEDIAWIKI_INSTALL', true );
1111
1212 chdir( ".." );
Index: branches/REL1_17/phase3/languages/messages/MessagesEn.php
@@ -1849,6 +1849,10 @@
18501850 'prefs-displaywatchlist' => 'Display options',
18511851 'prefs-diffs' => 'Diffs',
18521852
 1853+# User preference: email validation using JQuery
 1854+'email-address-validity-valid' => 'E-mail address appears valid',
 1855+'email-address-validity-invalid' => 'Enter a valid e-mail address',
 1856+
18531857 # User rights
18541858 'userrights' => 'User rights management',
18551859 'userrights-summary' => '', # do not translate or duplicate this message to other languages
@@ -3581,10 +3585,10 @@
35823586 'thumbsize' => 'Thumbnail size:',
35833587 'widthheight' => '$1×$2', # only translate this message to other languages if you have to change it
35843588 'widthheightpage' => '$1×$2, $3 {{PLURAL:$3|page|pages}}',
3585 -'file-info' => '(file size: $1, MIME type: $2)',
3586 -'file-info-size' => '($1 × $2 pixels, file size: $3, MIME type: $4)',
 3589+'file-info' => 'file size: $1, MIME type: $2',
 3590+'file-info-size' => '$1 × $2 pixels, file size: $3, MIME type: $4',
35873591 'file-nohires' => '<small>No higher resolution available.</small>',
3588 -'svg-long-desc' => '(SVG file, nominally $1 × $2 pixels, file size: $3)',
 3592+'svg-long-desc' => 'SVG file, nominally $1 × $2 pixels, file size: $3',
35893593 'show-big-image' => 'Full resolution',
35903594 'show-big-image-thumb' => '<small>Size of this preview: $1 × $2 pixels</small>',
35913595 'file-info-gif-looped' => 'looped',
Index: branches/REL1_17/phase3/resources/mediawiki.util/mediawiki.util.js
@@ -353,7 +353,7 @@
354354 "|" / "}" /
355355 "~"
356356 */
357 - var rfc5322_atext = "a-z0-9!#$%&'*+-/=?^_`{|}~",
 357+ var rfc5322_atext = "a-z0-9!#$%&'*+\\-/=?^_`{|}~",
358358
359359 /**
360360 * Next define the RFC 1034 'ldh-str'
@@ -364,14 +364,14 @@
365365 * <let-dig-hyp> ::= <let-dig> | "-"
366366 * <let-dig> ::= <letter> | <digit>
367367 */
368 - rfc1034_ldh_str = "a-z0-9-",
 368+ rfc1034_ldh_str = "a-z0-9\\-",
369369
370370 HTML5_email_regexp = new RegExp(
371371 // start of string
372372 '^'
373373 +
374374 // User part which is liberal :p
375 - '[' + rfc5322_atext + '\\.' + ']' + '+'
 375+ '[' + rfc5322_atext + '\\.]+'
376376 +
377377 // "at"
378378 '@'
Index: branches/REL1_17/phase3/resources/mediawiki/mediawiki.js
@@ -978,7 +978,7 @@
979979 */
980980 this.element = function( name, attrs, contents ) {
981981 var s = '<' + name;
982 - for ( attrName in attrs ) {
 982+ for ( var attrName in attrs ) {
983983 s += ' ' + attrName + '="' + this.escape( attrs[attrName] ) + '"';
984984 }
985985 if ( typeof contents == 'undefined' || contents === null ) {
@@ -988,7 +988,7 @@
989989 }
990990 // Regular open tag
991991 s += '>';
992 - if (typeof contents === 'string') {
 992+ if ( typeof contents === 'string') {
993993 // Escaped
994994 s += this.escape( contents );
995995 } else if ( contents instanceof this.Raw ) {
Property changes on: branches/REL1_17/phase3/resources/mediawiki/mediawiki.js
___________________________________________________________________
Modified: svn:mergeinfo
996996 Merged /trunk/phase3/resources/mediawiki/mediawiki.js:r79915,79957,79964,79990,80687,80999,81006,81011,81101,81105,81138,81141,81146,81149-81150,81166,81171

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r79915Correct {,in}valid js messages in UserPreferences...hashar20:30, 9 January 2011
r79957Follow-up r79915: Add new section in maintenance file tooraymond20:54, 10 January 2011
r79964Move the () surrounding description strings of files, out of the description ...hartman22:18, 10 January 2011
r79990Follow-up r79964: Use the existing message 'parentheses' instead of introduci...raymond07:37, 11 January 2011
r80687Partially revert r69738 (splitting Installer/CoreInstaller). As discussed on ...demon15:27, 21 January 2011
r80999The function wfShorthandToInteger() is precisely for that....platonides22:42, 25 January 2011
r81006generateUpgradeKey() could produce NULL return, which means a fatal error when...platonides23:37, 25 January 2011
r81011Transforming a message uses automatically $wgTitle, which may not be set if r...platonides00:23, 26 January 2011
r81101Bug 26948 - hyphens incorrectly interpreted as range...hashar20:52, 27 January 2011
r81105invalid 'var' in JS email validation...hashar21:14, 27 January 2011
r81138call parent constructor so that include path and other things work rightariel17:18, 28 January 2011
r81141JSMin is gone, please talk with JavaScriptDistiller...platonides17:51, 28 January 2011
r81146Random fixes in mediawiki.js: add a var, fix indentation, and get our ABC rightcatrope18:33, 28 January 2011
r81149open a series of files for xml input, if supplied (used for multiple xml pref...ariel19:16, 28 January 2011
r81150open a series of files for xml input, if supplied (used for multiple xml pref...ariel19:20, 28 January 2011
r81166(bug 26938) "wikipedia compatible" should not be part of the license name. We...demon21:07, 28 January 2011
r81171Update comments to take into account r80443 and r80614 changes, per CR.platonides22:27, 28 January 2011

Comments

#Comment by Hashar (talk | contribs)   17:34, 2 February 2011

Thanks :)

Status & tagging log