Index: trunk/phase3/includes/installer/Installer.php |
— | — | @@ -2,56 +2,56 @@ |
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Base installer class. |
6 | | - * |
| 6 | + * |
7 | 7 | * This class provides the base for installation and update functionality |
8 | 8 | * for both MediaWiki core and extensions. |
9 | | - * |
| 9 | + * |
10 | 10 | * @since 1.17 |
11 | 11 | */ |
12 | 12 | abstract class Installer { |
13 | | - |
| 13 | + |
14 | 14 | /** |
15 | 15 | * TODO: make protected? |
16 | | - * |
| 16 | + * |
17 | 17 | * @var array |
18 | 18 | */ |
19 | | - public $settings; |
20 | | - |
| 19 | + public $settings; |
| 20 | + |
21 | 21 | /** |
22 | 22 | * Cached DB installer instances, access using getDBInstaller(). |
23 | | - * |
| 23 | + * |
24 | 24 | * @var array |
25 | 25 | */ |
26 | 26 | protected $dbInstallers = array(); |
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Minimum memory size in MB. |
30 | | - * |
| 30 | + * |
31 | 31 | * @var integer |
32 | 32 | */ |
33 | | - protected $minMemorySize = 50; |
34 | | - |
| 33 | + protected $minMemorySize = 50; |
| 34 | + |
35 | 35 | /** |
36 | 36 | * Cached Title, used by parse(). |
37 | | - * |
| 37 | + * |
38 | 38 | * @var Title |
39 | 39 | */ |
40 | 40 | protected $parserTitle; |
41 | | - |
| 41 | + |
42 | 42 | /** |
43 | 43 | * Cached ParserOptions, used by parse(). |
44 | | - * |
| 44 | + * |
45 | 45 | * @var ParserOptions |
46 | | - */ |
47 | | - protected $parserOptions; |
48 | | - |
| 46 | + */ |
| 47 | + protected $parserOptions; |
| 48 | + |
49 | 49 | /** |
50 | 50 | * Known database types. These correspond to the class names <type>Installer, |
51 | 51 | * and are also MediaWiki database types valid for $wgDBtype. |
52 | 52 | * |
53 | 53 | * To add a new type, create a <type>Installer class and a Database<type> |
54 | 54 | * class, and add a config-type-<type> message to MessagesEn.php. |
55 | | - * |
| 55 | + * |
56 | 56 | * @var array |
57 | 57 | */ |
58 | 58 | protected $dbTypes = array( |
— | — | @@ -60,12 +60,12 @@ |
61 | 61 | 'sqlite', |
62 | 62 | 'oracle' |
63 | 63 | ); |
64 | | - |
| 64 | + |
65 | 65 | /** |
66 | 66 | * A list of environment check methods called by doEnvironmentChecks(). |
67 | 67 | * These may output warnings using showMessage(), and/or abort the |
68 | 68 | * installation process by returning false. |
69 | | - * |
| 69 | + * |
70 | 70 | * @var array |
71 | 71 | */ |
72 | 72 | protected $envChecks = array( |
— | — | @@ -89,8 +89,8 @@ |
90 | 90 | 'envCheckShellLocale', |
91 | 91 | 'envCheckUploadsDirectory', |
92 | 92 | 'envCheckLibicu' |
93 | | - ); |
94 | | - |
| 93 | + ); |
| 94 | + |
95 | 95 | /** |
96 | 96 | * UI interface for displaying a short message |
97 | 97 | * The parameters are like parameters to wfMsg(). |
— | — | @@ -98,23 +98,23 @@ |
99 | 99 | * output format such as HTML or text before being sent to the user. |
100 | 100 | */ |
101 | 101 | public abstract function showMessage( $msg /*, ... */ ); |
102 | | - |
| 102 | + |
103 | 103 | /** |
104 | 104 | * Constructor, always call this from child classes. |
105 | 105 | */ |
106 | | - public function __construct() { |
| 106 | + public function __construct() { |
107 | 107 | // Disable the i18n cache and LoadBalancer |
108 | 108 | Language::getLocalisationCache()->disableBackend(); |
109 | 109 | LBFactory::disableBackend(); |
110 | 110 | } |
111 | | - |
| 111 | + |
112 | 112 | /** |
113 | 113 | * Get a list of known DB types. |
114 | 114 | */ |
115 | 115 | public function getDBTypes() { |
116 | 116 | return $this->dbTypes; |
117 | | - } |
118 | | - |
| 117 | + } |
| 118 | + |
119 | 119 | /** |
120 | 120 | * Do initial checks of the PHP environment. Set variables according to |
121 | 121 | * the observed environment. |
— | — | @@ -125,35 +125,35 @@ |
126 | 126 | * |
127 | 127 | * Under the web subclass, it can already be assumed that PHP 5+ is in use |
128 | 128 | * and that sessions are working. |
129 | | - * |
| 129 | + * |
130 | 130 | * @return boolean |
131 | 131 | */ |
132 | 132 | public function doEnvironmentChecks() { |
133 | 133 | $this->showMessage( 'config-env-php', phpversion() ); |
134 | 134 | |
135 | 135 | $good = true; |
136 | | - |
| 136 | + |
137 | 137 | foreach ( $this->envChecks as $check ) { |
138 | 138 | $status = $this->$check(); |
139 | 139 | if ( $status === false ) { |
140 | 140 | $good = false; |
141 | 141 | } |
142 | 142 | } |
143 | | - |
| 143 | + |
144 | 144 | $this->setVar( '_Environment', $good ); |
145 | | - |
| 145 | + |
146 | 146 | if ( $good ) { |
147 | 147 | $this->showMessage( 'config-env-good' ); |
148 | 148 | } else { |
149 | 149 | $this->showMessage( 'config-env-bad' ); |
150 | 150 | } |
151 | | - |
| 151 | + |
152 | 152 | return $good; |
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
156 | 156 | * Set a MW configuration variable, or internal installer configuration variable. |
157 | | - * |
| 157 | + * |
158 | 158 | * @param $name String |
159 | 159 | * @param $value Mixed |
160 | 160 | */ |
— | — | @@ -165,10 +165,10 @@ |
166 | 166 | * Get an MW configuration variable, or internal installer configuration variable. |
167 | 167 | * The defaults come from $GLOBALS (ultimately DefaultSettings.php). |
168 | 168 | * Installer variables are typically prefixed by an underscore. |
169 | | - * |
| 169 | + * |
170 | 170 | * @param $name String |
171 | 171 | * @param $default Mixed |
172 | | - * |
| 172 | + * |
173 | 173 | * @return mixed |
174 | 174 | */ |
175 | 175 | public function getVar( $name, $default = null ) { |
— | — | @@ -177,34 +177,34 @@ |
178 | 178 | } else { |
179 | 179 | return $this->settings[$name]; |
180 | 180 | } |
181 | | - } |
182 | | - |
| 181 | + } |
| 182 | + |
183 | 183 | /** |
184 | 184 | * Get an instance of DatabaseInstaller for the specified DB type. |
185 | | - * |
| 185 | + * |
186 | 186 | * @param $type Mixed: DB installer for which is needed, false to use default. |
187 | | - * |
| 187 | + * |
188 | 188 | * @return DatabaseInstaller |
189 | 189 | */ |
190 | 190 | public function getDBInstaller( $type = false ) { |
191 | 191 | if ( !$type ) { |
192 | 192 | $type = $this->getVar( 'wgDBtype' ); |
193 | 193 | } |
194 | | - |
| 194 | + |
195 | 195 | $type = strtolower( $type ); |
196 | 196 | |
197 | 197 | if ( !isset( $this->dbInstallers[$type] ) ) { |
198 | 198 | $class = ucfirst( $type ). 'Installer'; |
199 | 199 | $this->dbInstallers[$type] = new $class( $this ); |
200 | 200 | } |
201 | | - |
| 201 | + |
202 | 202 | return $this->dbInstallers[$type]; |
203 | | - } |
204 | | - |
| 203 | + } |
| 204 | + |
205 | 205 | /** |
206 | 206 | * Determine if LocalSettings exists. If it does, return an appropriate |
207 | 207 | * status for whether we should can upgrade or not. |
208 | | - * |
| 208 | + * |
209 | 209 | * @return Status |
210 | 210 | */ |
211 | 211 | public function getLocalSettingsStatus() { |
— | — | @@ -224,17 +224,17 @@ |
225 | 225 | $status->fatal( 'config-localsettings-noupgrade' ); |
226 | 226 | } |
227 | 227 | } |
228 | | - |
| 228 | + |
229 | 229 | return $status; |
230 | | - } |
231 | | - |
| 230 | + } |
| 231 | + |
232 | 232 | /** |
233 | 233 | * Get a fake password for sending back to the user in HTML. |
234 | 234 | * This is a security mechanism to avoid compromise of the password in the |
235 | 235 | * event of session ID compromise. |
236 | | - * |
| 236 | + * |
237 | 237 | * @param $realPassword String |
238 | | - * |
| 238 | + * |
239 | 239 | * @return string |
240 | 240 | */ |
241 | 241 | public function getFakePassword( $realPassword ) { |
— | — | @@ -244,7 +244,7 @@ |
245 | 245 | /** |
246 | 246 | * Set a variable which stores a password, except if the new value is a |
247 | 247 | * fake password in which case leave it as it is. |
248 | | - * |
| 248 | + * |
249 | 249 | * @param $name String |
250 | 250 | * @param $value Mixed |
251 | 251 | */ |
— | — | @@ -252,7 +252,7 @@ |
253 | 253 | if ( !preg_match( '/^\*+$/', $value ) ) { |
254 | 254 | $this->setVar( $name, $value ); |
255 | 255 | } |
256 | | - } |
| 256 | + } |
257 | 257 | |
258 | 258 | /** |
259 | 259 | * On POSIX systems return the primary group of the webserver we're running under. |
— | — | @@ -278,8 +278,8 @@ |
279 | 279 | $group = $getpwuid['name']; |
280 | 280 | |
281 | 281 | return $group; |
282 | | - } |
283 | | - |
| 282 | + } |
| 283 | + |
284 | 284 | /** |
285 | 285 | * Convert wikitext $text to HTML. |
286 | 286 | * |
— | — | @@ -298,26 +298,26 @@ |
299 | 299 | */ |
300 | 300 | public function parse( $text, $lineStart = false ) { |
301 | 301 | global $wgParser; |
302 | | - |
| 302 | + |
303 | 303 | try { |
304 | 304 | $out = $wgParser->parse( $text, $this->parserTitle, $this->parserOptions, $lineStart ); |
305 | 305 | $html = $out->getText(); |
306 | 306 | } catch ( DBAccessError $e ) { |
307 | 307 | $html = '<!--DB access attempted during parse--> ' . htmlspecialchars( $text ); |
308 | | - |
| 308 | + |
309 | 309 | if ( !empty( $this->debug ) ) { |
310 | 310 | $html .= "<!--\n" . $e->getTraceAsString() . "\n-->"; |
311 | 311 | } |
312 | 312 | } |
313 | | - |
| 313 | + |
314 | 314 | return $html; |
315 | | - } |
316 | | - |
| 315 | + } |
| 316 | + |
317 | 317 | /** |
318 | 318 | * TODO: document |
319 | | - * |
| 319 | + * |
320 | 320 | * @param DatabaseInstaller $installer |
321 | | - * |
| 321 | + * |
322 | 322 | * @return Status |
323 | 323 | */ |
324 | 324 | public function installDatabase( DatabaseInstaller &$installer ) { |
— | — | @@ -327,38 +327,38 @@ |
328 | 328 | } else { |
329 | 329 | $status = $installer->setupDatabase(); |
330 | 330 | } |
331 | | - |
| 331 | + |
332 | 332 | return $status; |
333 | 333 | } |
334 | 334 | |
335 | 335 | /** |
336 | 336 | * TODO: document |
337 | | - * |
| 337 | + * |
338 | 338 | * @param DatabaseInstaller $installer |
339 | | - * |
| 339 | + * |
340 | 340 | * @return Status |
341 | 341 | */ |
342 | 342 | public function installTables( DatabaseInstaller &$installer ) { |
343 | 343 | $status = $installer->createTables(); |
344 | | - |
| 344 | + |
345 | 345 | if( $status->isOK() ) { |
346 | 346 | LBFactory::enableBackend(); |
347 | 347 | } |
348 | | - |
| 348 | + |
349 | 349 | return $status; |
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
353 | 353 | * TODO: document |
354 | | - * |
| 354 | + * |
355 | 355 | * @param DatabaseInstaller $installer |
356 | | - * |
| 356 | + * |
357 | 357 | * @return Status |
358 | | - */ |
| 358 | + */ |
359 | 359 | public function installInterwiki( DatabaseInstaller &$installer ) { |
360 | 360 | return $installer->populateInterwikiTable(); |
361 | | - } |
362 | | - |
| 361 | + } |
| 362 | + |
363 | 363 | /** |
364 | 364 | * Exports all wg* variables stored by the installer into global scope. |
365 | 365 | */ |
— | — | @@ -368,45 +368,45 @@ |
369 | 369 | $GLOBALS[$name] = $value; |
370 | 370 | } |
371 | 371 | } |
372 | | - } |
373 | | - |
| 372 | + } |
| 373 | + |
374 | 374 | /** |
375 | 375 | * Check if we're installing the latest version. |
376 | 376 | */ |
377 | 377 | public function envLatestVersion() { |
378 | 378 | global $wgVersion; |
379 | | - |
| 379 | + |
380 | 380 | $latestInfoUrl = 'http://www.mediawiki.org/w/api.php?action=mwreleases&format=json'; |
381 | 381 | $latestInfo = Http::get( $latestInfoUrl ); |
382 | | - |
| 382 | + |
383 | 383 | if( !$latestInfo ) { |
384 | 384 | $this->showMessage( 'config-env-latest-can-not-check', $latestInfoUrl ); |
385 | 385 | return; |
386 | 386 | } |
387 | | - |
| 387 | + |
388 | 388 | $this->setVar( '_ExternalHTTP', true ); |
389 | 389 | $latestInfo = FormatJson::decode($latestInfo); |
390 | | - |
| 390 | + |
391 | 391 | if ($latestInfo === false || !isset( $latestInfo->mwreleases ) ) { |
392 | 392 | # For when the request is successful but there's e.g. some silly man in |
393 | 393 | # the middle firewall blocking us, e.g. one of those annoying airport ones |
394 | 394 | $this->showMessage( 'config-env-latest-data-invalid', $latestInfoUrl ); |
395 | 395 | return; |
396 | 396 | } |
397 | | - |
| 397 | + |
398 | 398 | foreach( $latestInfo->mwreleases as $rel ) { |
399 | 399 | if( isset( $rel->current ) ) { |
400 | 400 | $currentVersion = $rel->version; |
401 | 401 | } |
402 | 402 | } |
403 | | - |
| 403 | + |
404 | 404 | if( version_compare( $wgVersion, $currentVersion, '<' ) ) { |
405 | 405 | $this->showMessage( 'config-env-latest-old' ); |
406 | 406 | $this->showHelpBox( 'config-env-latest-help', $wgVersion, $currentVersion ); |
407 | 407 | } elseif( version_compare( $wgVersion, $currentVersion, '>' ) ) { |
408 | 408 | $this->showMessage( 'config-env-latest-new' ); |
409 | 409 | } |
410 | | - |
| 410 | + |
411 | 411 | $this->showMessage( 'config-env-latest-ok' ); |
412 | 412 | } |
413 | 413 | |
— | — | @@ -415,31 +415,31 @@ |
416 | 416 | */ |
417 | 417 | public function envCheckDB() { |
418 | 418 | global $wgLang; |
419 | | - |
| 419 | + |
420 | 420 | $compiledDBs = array(); |
421 | 421 | $goodNames = array(); |
422 | 422 | $allNames = array(); |
423 | | - |
| 423 | + |
424 | 424 | foreach ( $this->dbTypes as $name ) { |
425 | 425 | $db = $this->getDBInstaller( $name ); |
426 | 426 | $readableName = wfMsg( 'config-type-' . $name ); |
427 | | - |
| 427 | + |
428 | 428 | if ( $db->isCompiled() ) { |
429 | 429 | $compiledDBs[] = $name; |
430 | 430 | $goodNames[] = $readableName; |
431 | 431 | } |
432 | | - |
| 432 | + |
433 | 433 | $allNames[] = $readableName; |
434 | 434 | } |
435 | | - |
| 435 | + |
436 | 436 | $this->setVar( '_CompiledDBs', $compiledDBs ); |
437 | | - |
| 437 | + |
438 | 438 | if ( !$compiledDBs ) { |
439 | 439 | $this->showMessage( 'config-no-db' ); |
440 | 440 | $this->showHelpBox( 'config-no-db-help', $wgLang->commaList( $allNames ) ); |
441 | 441 | return false; |
442 | 442 | } |
443 | | - |
| 443 | + |
444 | 444 | $this->showMessage( 'config-have-db', $wgLang->commaList( $goodNames ) ); |
445 | 445 | } |
446 | 446 | |
— | — | @@ -528,21 +528,21 @@ |
529 | 529 | */ |
530 | 530 | public function envCheckMemory() { |
531 | 531 | $limit = ini_get( 'memory_limit' ); |
532 | | - |
| 532 | + |
533 | 533 | if ( !$limit || $limit == -1 ) { |
534 | 534 | $this->showMessage( 'config-memory-none' ); |
535 | 535 | return true; |
536 | 536 | } |
537 | | - |
| 537 | + |
538 | 538 | $n = intval( $limit ); |
539 | | - |
| 539 | + |
540 | 540 | if( preg_match( '/^([0-9]+)[Mm]$/', trim( $limit ), $m ) ) { |
541 | 541 | $n = intval( $m[1] * ( 1024 * 1024 ) ); |
542 | 542 | } |
543 | | - |
| 543 | + |
544 | 544 | if( $n < $this->minMemorySize * 1024 * 1024 ) { |
545 | 545 | $newLimit = "{$this->minMemorySize}M"; |
546 | | - |
| 546 | + |
547 | 547 | if( ini_set( "memory_limit", $newLimit ) === false ) { |
548 | 548 | $this->showMessage( 'config-memory-bad', $limit ); |
549 | 549 | } else { |
— | — | @@ -559,18 +559,18 @@ |
560 | 560 | */ |
561 | 561 | public function envCheckCache() { |
562 | 562 | $caches = array(); |
563 | | - |
| 563 | + |
564 | 564 | foreach ( $this->objectCaches as $name => $function ) { |
565 | 565 | if ( function_exists( $function ) ) { |
566 | 566 | $caches[$name] = true; |
567 | 567 | $this->showMessage( 'config-' . $name ); |
568 | 568 | } |
569 | 569 | } |
570 | | - |
| 570 | + |
571 | 571 | if ( !$caches ) { |
572 | 572 | $this->showMessage( 'config-no-cache' ); |
573 | 573 | } |
574 | | - |
| 574 | + |
575 | 575 | $this->setVar( '_Caches', $caches ); |
576 | 576 | } |
577 | 577 | |
— | — | @@ -588,55 +588,55 @@ |
589 | 589 | ), |
590 | 590 | explode( PATH_SEPARATOR, getenv( "PATH" ) ) |
591 | 591 | ); |
592 | | - |
| 592 | + |
593 | 593 | $names = array( "gdiff3", "diff3", "diff3.exe" ); |
594 | 594 | $versionInfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' ); |
595 | | - |
| 595 | + |
596 | 596 | $haveDiff3 = false; |
597 | | - |
| 597 | + |
598 | 598 | foreach ( $paths as $path ) { |
599 | 599 | $exe = $this->locateExecutable( $path, $names, $versionInfo ); |
600 | | - |
| 600 | + |
601 | 601 | if ($exe !== false) { |
602 | 602 | $this->setVar( 'wgDiff3', $exe ); |
603 | 603 | $haveDiff3 = true; |
604 | 604 | break; |
605 | 605 | } |
606 | 606 | } |
607 | | - |
| 607 | + |
608 | 608 | if ( $haveDiff3 ) { |
609 | 609 | $this->showMessage( 'config-diff3-good', $exe ); |
610 | 610 | } else { |
611 | 611 | $this->setVar( 'wgDiff3', false ); |
612 | 612 | $this->showMessage( 'config-diff3-bad' ); |
613 | 613 | } |
614 | | - } |
615 | | - |
| 614 | + } |
| 615 | + |
616 | 616 | /** |
617 | 617 | * Environment check for ImageMagick and GD. |
618 | 618 | */ |
619 | 619 | public function envCheckGraphics() { |
620 | 620 | $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" ); |
621 | | - |
| 621 | + |
622 | 622 | foreach( $imcheck as $dir ) { |
623 | 623 | $im = "$dir/convert"; |
624 | | - |
| 624 | + |
625 | 625 | wfSuppressWarnings(); |
626 | 626 | $file_exists = file_exists( $im ); |
627 | | - wfRestoreWarnings(); |
628 | | - |
| 627 | + wfRestoreWarnings(); |
| 628 | + |
629 | 629 | if( $file_exists ) { |
630 | 630 | $this->showMessage( 'config-imagemagick', $im ); |
631 | 631 | $this->setVar( 'wgImageMagickConvertCommand', $im ); |
632 | 632 | return true; |
633 | 633 | } |
634 | 634 | } |
635 | | - |
| 635 | + |
636 | 636 | if ( function_exists( 'imagejpeg' ) ) { |
637 | 637 | $this->showMessage( 'config-gd' ); |
638 | 638 | return true; |
639 | 639 | } |
640 | | - |
| 640 | + |
641 | 641 | $this->showMessage( 'no-scaling' ); |
642 | 642 | } |
643 | 643 | |
— | — | @@ -646,7 +646,7 @@ |
647 | 647 | public function envCheckPath() { |
648 | 648 | global $IP; |
649 | 649 | $IP = dirname( dirname( dirname( __FILE__ ) ) ); |
650 | | - |
| 650 | + |
651 | 651 | $this->setVar( 'IP', $IP ); |
652 | 652 | $this->showMessage( 'config-dir', $IP ); |
653 | 653 | |
— | — | @@ -664,7 +664,7 @@ |
665 | 665 | $this->showMessage( 'config-no-uri' ); |
666 | 666 | return false; |
667 | 667 | } |
668 | | - |
| 668 | + |
669 | 669 | $uri = preg_replace( '{^(.*)/config.*$}', '$1', $path ); |
670 | 670 | $this->setVar( 'wgScriptPath', $uri ); |
671 | 671 | $this->showMessage( 'config-uri', $uri ); |
— | — | @@ -676,16 +676,16 @@ |
677 | 677 | public function envCheckWriteableDir() { |
678 | 678 | $ipDir = $this->getVar( 'IP' ); |
679 | 679 | $configDir = $ipDir . '/config'; |
680 | | - |
| 680 | + |
681 | 681 | if( !is_writeable( $configDir ) ) { |
682 | 682 | $webserverGroup = self::maybeGetWebserverPrimaryGroup(); |
683 | | - |
| 683 | + |
684 | 684 | if ( $webserverGroup !== null ) { |
685 | 685 | $this->showMessage( 'config-dir-not-writable-group', $ipDir, $webserverGroup ); |
686 | 686 | } else { |
687 | 687 | $this->showMessage( 'config-dir-not-writable-nogroup', $ipDir, $webserverGroup ); |
688 | 688 | } |
689 | | - |
| 689 | + |
690 | 690 | return false; |
691 | 691 | } |
692 | 692 | } |
— | — | @@ -700,7 +700,7 @@ |
701 | 701 | } else { |
702 | 702 | $ext = 'php'; |
703 | 703 | } |
704 | | - |
| 704 | + |
705 | 705 | $this->setVar( 'wgScriptExtension', ".$ext" ); |
706 | 706 | $this->showMessage( 'config-file-extension', $ext ); |
707 | 707 | } |
— | — | @@ -717,7 +717,7 @@ |
718 | 718 | |
719 | 719 | $os = php_uname( 's' ); |
720 | 720 | $supported = array( 'Linux', 'SunOS', 'HP-UX' ); # Tested these |
721 | | - |
| 721 | + |
722 | 722 | if ( !in_array( $os, $supported ) ) { |
723 | 723 | return true; |
724 | 724 | } |
— | — | @@ -725,7 +725,7 @@ |
726 | 726 | # Get a list of available locales. |
727 | 727 | $lines = $ret = false; |
728 | 728 | exec( '/usr/bin/locale -a', $lines, $ret ); |
729 | | - |
| 729 | + |
730 | 730 | if ( $ret ) { |
731 | 731 | return true; |
732 | 732 | } |
— | — | @@ -733,18 +733,18 @@ |
734 | 734 | $lines = wfArrayMap( 'trim', $lines ); |
735 | 735 | $candidatesByLocale = array(); |
736 | 736 | $candidatesByLang = array(); |
737 | | - |
| 737 | + |
738 | 738 | foreach ( $lines as $line ) { |
739 | 739 | if ( $line === '' ) { |
740 | 740 | continue; |
741 | 741 | } |
742 | | - |
| 742 | + |
743 | 743 | if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) { |
744 | 744 | continue; |
745 | 745 | } |
746 | | - |
| 746 | + |
747 | 747 | list( $all, $lang, $territory, $charset, $modifier ) = $m; |
748 | | - |
| 748 | + |
749 | 749 | $candidatesByLocale[$m[0]] = $m; |
750 | 750 | $candidatesByLang[$lang][] = $m; |
751 | 751 | } |
— | — | @@ -768,7 +768,7 @@ |
769 | 769 | |
770 | 770 | # Is there an available locale in the Wiki's language? |
771 | 771 | $wikiLang = $this->getVar( 'wgLanguageCode' ); |
772 | | - |
| 772 | + |
773 | 773 | if ( isset( $candidatesByLang[$wikiLang] ) ) { |
774 | 774 | $m = reset( $candidatesByLang[$wikiLang] ); |
775 | 775 | $this->setVar( 'wgShellLocale', $m[0] ); |
— | — | @@ -793,18 +793,18 @@ |
794 | 794 | */ |
795 | 795 | public function envCheckUploadsDirectory() { |
796 | 796 | global $IP, $wgServer; |
797 | | - |
| 797 | + |
798 | 798 | $dir = $IP . '/images/'; |
799 | 799 | $url = $wgServer . $this->getVar( 'wgScriptPath' ) . '/images/'; |
800 | 800 | $safe = !$this->dirIsExecutable( $dir, $url ); |
801 | | - |
| 801 | + |
802 | 802 | if ( $safe ) { |
803 | 803 | $this->showMessage( 'config-uploads-safe' ); |
804 | 804 | } else { |
805 | 805 | $this->showMessage( 'config-uploads-not-safe', $dir ); |
806 | 806 | } |
807 | | - } |
808 | | - |
| 807 | + } |
| 808 | + |
809 | 809 | /** |
810 | 810 | * Convert a hex string representing a Unicode code point to that code point. |
811 | 811 | * @param string $c |
— | — | @@ -872,7 +872,7 @@ |
873 | 873 | * Search a path for any of the given executable names. Returns the |
874 | 874 | * executable name if found. Also checks the version string returned |
875 | 875 | * by each executable. |
876 | | - * |
| 876 | + * |
877 | 877 | * Used only by environment checks. |
878 | 878 | * |
879 | 879 | * @param $path String: path to search |
— | — | @@ -891,18 +891,18 @@ |
892 | 892 | |
893 | 893 | foreach ( $names as $name ) { |
894 | 894 | $command = "$path/$name"; |
895 | | - |
| 895 | + |
896 | 896 | wfSuppressWarnings(); |
897 | 897 | $file_exists = file_exists( $command ); |
898 | 898 | wfRestoreWarnings(); |
899 | | - |
| 899 | + |
900 | 900 | if ( $file_exists ) { |
901 | 901 | if ( !$versionInfo ) { |
902 | 902 | return $command; |
903 | 903 | } |
904 | | - |
| 904 | + |
905 | 905 | $file = str_replace( '$1', $command, $versionInfo[0] ); |
906 | | - |
| 906 | + |
907 | 907 | # Should maybe be wfShellExec( $file), but runs into a ulimit, see |
908 | 908 | # http://www.mediawiki.org/w/index.php?title=New-installer_issues&diff=prev&oldid=335456 |
909 | 909 | if ( strstr( `$file`, $versionInfo[1]) !== false ) { |
— | — | @@ -910,13 +910,13 @@ |
911 | 911 | } |
912 | 912 | } |
913 | 913 | } |
914 | | - |
| 914 | + |
915 | 915 | return false; |
916 | | - } |
917 | | - |
| 916 | + } |
| 917 | + |
918 | 918 | /** |
919 | 919 | * Checks if scripts located in the given directory can be executed via the given URL. |
920 | | - * |
| 920 | + * |
921 | 921 | * Used only by environment checks. |
922 | 922 | */ |
923 | 923 | public function dirIsExecutable( $dir, $url ) { |
— | — | @@ -926,32 +926,32 @@ |
927 | 927 | "#!/var/env php5\n<?php echo 'ex' . 'ec';", |
928 | 928 | ), |
929 | 929 | ); |
930 | | - |
| 930 | + |
931 | 931 | // it would be good to check other popular languages here, but it'll be slow. |
932 | 932 | |
933 | 933 | wfSuppressWarnings(); |
934 | | - |
| 934 | + |
935 | 935 | foreach ( $scriptTypes as $ext => $contents ) { |
936 | 936 | foreach ( $contents as $source ) { |
937 | 937 | $file = 'exectest.' . $ext; |
938 | | - |
| 938 | + |
939 | 939 | if ( !file_put_contents( $dir . $file, $source ) ) { |
940 | 940 | break; |
941 | 941 | } |
942 | | - |
| 942 | + |
943 | 943 | $text = Http::get( $url . $file ); |
944 | 944 | unlink( $dir . $file ); |
945 | | - |
| 945 | + |
946 | 946 | if ( $text == 'exec' ) { |
947 | 947 | wfRestoreWarnings(); |
948 | 948 | return $ext; |
949 | 949 | } |
950 | 950 | } |
951 | 951 | } |
952 | | - |
| 952 | + |
953 | 953 | wfRestoreWarnings(); |
954 | | - |
| 954 | + |
955 | 955 | return false; |
956 | | - } |
957 | | - |
| 956 | + } |
| 957 | + |
958 | 958 | } |