MediaWiki REL1_28
Installer.php
Go to the documentation of this file.
1<?php
27
43abstract class Installer {
44
51 const MINIMUM_PCRE_VERSION = '7.2';
52
56 protected $settings;
57
63 protected $compiledDBs;
64
70 protected $dbInstallers = [];
71
77 protected $minMemorySize = 50;
78
84 protected $parserTitle;
85
91 protected $parserOptions;
92
102 protected static $dbTypes = [
103 'mysql',
104 'postgres',
105 'oracle',
106 'mssql',
107 'sqlite',
108 ];
109
121 protected $envChecks = [
122 'envCheckDB',
123 'envCheckBrokenXML',
124 'envCheckPCRE',
125 'envCheckMemory',
126 'envCheckCache',
127 'envCheckModSecurity',
128 'envCheckDiff3',
129 'envCheckGraphics',
130 'envCheckGit',
131 'envCheckServer',
132 'envCheckPath',
133 'envCheckShellLocale',
134 'envCheckUploadsDirectory',
135 'envCheckLibicu',
136 'envCheckSuhosinMaxValueLength',
137 ];
138
144 protected $envPreps = [
145 'envPrepServer',
146 'envPrepPath',
147 ];
148
156 protected $defaultVarNames = [
157 'wgSitename',
158 'wgPasswordSender',
159 'wgLanguageCode',
160 'wgRightsIcon',
161 'wgRightsText',
162 'wgRightsUrl',
163 'wgEnableEmail',
164 'wgEnableUserEmail',
165 'wgEnotifUserTalk',
166 'wgEnotifWatchlist',
167 'wgEmailAuthentication',
168 'wgDBname',
169 'wgDBtype',
170 'wgDiff3',
171 'wgImageMagickConvertCommand',
172 'wgGitBin',
173 'IP',
174 'wgScriptPath',
175 'wgMetaNamespace',
176 'wgDeletedDirectory',
177 'wgEnableUploads',
178 'wgShellLocale',
179 'wgSecretKey',
180 'wgUseInstantCommons',
181 'wgUpgradeKey',
182 'wgDefaultSkin',
183 'wgPingback',
184 ];
185
193 protected $internalDefaults = [
194 '_UserLang' => 'en',
195 '_Environment' => false,
196 '_RaiseMemory' => false,
197 '_UpgradeDone' => false,
198 '_InstallDone' => false,
199 '_Caches' => [],
200 '_InstallPassword' => '',
201 '_SameAccount' => true,
202 '_CreateDBAccount' => false,
203 '_NamespaceType' => 'site-name',
204 '_AdminName' => '', // will be set later, when the user selects language
205 '_AdminPassword' => '',
206 '_AdminPasswordConfirm' => '',
207 '_AdminEmail' => '',
208 '_Subscribe' => false,
209 '_SkipOptional' => 'continue',
210 '_RightsProfile' => 'wiki',
211 '_LicenseCode' => 'none',
212 '_CCDone' => false,
213 '_Extensions' => [],
214 '_Skins' => [],
215 '_MemCachedServers' => '',
216 '_UpgradeKeySupplied' => false,
217 '_ExistingDBSettings' => false,
218
219 // $wgLogo is probably wrong (bug 48084); set something that will work.
220 // Single quotes work fine here, as LocalSettingsGenerator outputs this unescaped.
221 'wgLogo' => '$wgResourceBasePath/resources/assets/wiki.png',
222 'wgAuthenticationTokenVersion' => 1,
223 ];
224
230 private $installSteps = [];
231
237 protected $extraInstallSteps = [];
238
244 protected $objectCaches = [
245 'xcache' => 'xcache_get',
246 'apc' => 'apc_fetch',
247 'apcu' => 'apcu_fetch',
248 'wincache' => 'wincache_ucache_get'
249 ];
250
257 'wiki' => [],
258 'no-anon' => [
259 '*' => [ 'edit' => false ]
260 ],
261 'fishbowl' => [
262 '*' => [
263 'createaccount' => false,
264 'edit' => false,
265 ],
266 ],
267 'private' => [
268 '*' => [
269 'createaccount' => false,
270 'edit' => false,
271 'read' => false,
272 ],
273 ],
274 ];
275
281 public $licenses = [
282 'cc-by' => [
283 'url' => 'https://creativecommons.org/licenses/by/4.0/',
284 'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-by.png',
285 ],
286 'cc-by-sa' => [
287 'url' => 'https://creativecommons.org/licenses/by-sa/4.0/',
288 'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-by-sa.png',
289 ],
290 'cc-by-nc-sa' => [
291 'url' => 'https://creativecommons.org/licenses/by-nc-sa/4.0/',
292 'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-by-nc-sa.png',
293 ],
294 'cc-0' => [
295 'url' => 'https://creativecommons.org/publicdomain/zero/1.0/',
296 'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-0.png',
297 ],
298 'gfdl' => [
299 'url' => 'https://www.gnu.org/copyleft/fdl.html',
300 'icon' => '$wgResourceBasePath/resources/assets/licenses/gnu-fdl.png',
301 ],
302 'none' => [
303 'url' => '',
304 'icon' => '',
305 'text' => ''
306 ],
307 'cc-choose' => [
308 // Details will be filled in by the selector.
309 'url' => '',
310 'icon' => '',
311 'text' => '',
312 ],
313 ];
314
319 'https://lists.wikimedia.org/mailman/subscribe/mediawiki-announce';
320
325 'ca', 'cs', 'da', 'de', 'en', 'es', 'et', 'eu', 'fi', 'fr', 'hr', 'hu',
326 'it', 'ja', 'ko', 'lt', 'nl', 'no', 'pl', 'pt', 'pt-br', 'ro', 'ru',
327 'sl', 'sr', 'sv', 'tr', 'uk'
328 ];
329
337 abstract public function showMessage( $msg /*, ... */ );
338
343 abstract public function showError( $msg /*, ... */ );
344
349 abstract public function showStatusMessage( Status $status );
350
361 public static function getInstallerConfig( Config $baseConfig ) {
362 $configOverrides = new HashConfig();
363
364 // disable (problematic) object cache types explicitly, preserving all other (working) ones
365 // bug T113843
366 $emptyCache = [ 'class' => 'EmptyBagOStuff' ];
367
368 $objectCaches = [
369 CACHE_NONE => $emptyCache,
370 CACHE_DB => $emptyCache,
371 CACHE_ANYTHING => $emptyCache,
372 CACHE_MEMCACHED => $emptyCache,
373 ] + $baseConfig->get( 'ObjectCaches' );
374
375 $configOverrides->set( 'ObjectCaches', $objectCaches );
376
377 // Load the installer's i18n.
378 $messageDirs = $baseConfig->get( 'MessagesDirs' );
379 $messageDirs['MediawikiInstaller'] = __DIR__ . '/i18n';
380
381 $configOverrides->set( 'MessagesDirs', $messageDirs );
382
383 $installerConfig = new MultiConfig( [ $configOverrides, $baseConfig ] );
384
385 // make sure we use the installer config as the main config
386 $configRegistry = $baseConfig->get( 'ConfigRegistry' );
387 $configRegistry['main'] = function() use ( $installerConfig ) {
388 return $installerConfig;
389 };
390
391 $configOverrides->set( 'ConfigRegistry', $configRegistry );
392
393 return $installerConfig;
394 }
395
399 public function __construct() {
401
402 $defaultConfig = new GlobalVarConfig(); // all the stuff from DefaultSettings.php
403 $installerConfig = self::getInstallerConfig( $defaultConfig );
404
405 // Reset all services and inject config overrides
406 MediaWiki\MediaWikiServices::resetGlobalInstance( $installerConfig );
407
408 // Don't attempt to load user language options (T126177)
409 // This will be overridden in the web installer with the user-specified language
410 RequestContext::getMain()->setLanguage( 'en' );
411
412 // Disable the i18n cache
413 // TODO: manage LocalisationCache singleton in MediaWikiServices
414 Language::getLocalisationCache()->disableBackend();
415
416 // Disable all global services, since we don't have any configuration yet!
417 MediaWiki\MediaWikiServices::disableStorageBackend();
418
419 // Disable object cache (otherwise CACHE_ANYTHING will try CACHE_DB and
420 // SqlBagOStuff will then throw since we just disabled wfGetDB)
421 $wgObjectCaches = MediaWikiServices::getInstance()->getMainConfig()->get( 'ObjectCaches' );
422 $wgMemc = ObjectCache::getInstance( CACHE_NONE );
423
424 // Having a user with id = 0 safeguards us from DB access via User::loadOptions().
425 $wgUser = User::newFromId( 0 );
426 RequestContext::getMain()->setUser( $wgUser );
427
429
430 foreach ( $this->defaultVarNames as $var ) {
431 $this->settings[$var] = $GLOBALS[$var];
432 }
433
434 $this->doEnvironmentPreps();
435
436 $this->compiledDBs = [];
437 foreach ( self::getDBTypes() as $type ) {
438 $installer = $this->getDBInstaller( $type );
439
440 if ( !$installer->isCompiled() ) {
441 continue;
442 }
443 $this->compiledDBs[] = $type;
444 }
445
446 $this->parserTitle = Title::newFromText( 'Installer' );
447 $this->parserOptions = new ParserOptions( $wgUser ); // language will be wrong :(
448 $this->parserOptions->setEditSection( false );
449 }
450
456 public static function getDBTypes() {
457 return self::$dbTypes;
458 }
459
473 public function doEnvironmentChecks() {
474 // Php version has already been checked by entry scripts
475 // Show message here for information purposes
476 if ( wfIsHHVM() ) {
477 $this->showMessage( 'config-env-hhvm', HHVM_VERSION );
478 } else {
479 $this->showMessage( 'config-env-php', PHP_VERSION );
480 }
481
482 $good = true;
483 // Must go here because an old version of PCRE can prevent other checks from completing
484 list( $pcreVersion ) = explode( ' ', PCRE_VERSION, 2 );
485 if ( version_compare( $pcreVersion, self::MINIMUM_PCRE_VERSION, '<' ) ) {
486 $this->showError( 'config-pcre-old', self::MINIMUM_PCRE_VERSION, $pcreVersion );
487 $good = false;
488 } else {
489 foreach ( $this->envChecks as $check ) {
490 $status = $this->$check();
491 if ( $status === false ) {
492 $good = false;
493 }
494 }
495 }
496
497 $this->setVar( '_Environment', $good );
498
499 return $good ? Status::newGood() : Status::newFatal( 'config-env-bad' );
500 }
501
502 public function doEnvironmentPreps() {
503 foreach ( $this->envPreps as $prep ) {
504 $this->$prep();
505 }
506 }
507
514 public function setVar( $name, $value ) {
515 $this->settings[$name] = $value;
516 }
517
528 public function getVar( $name, $default = null ) {
529 if ( !isset( $this->settings[$name] ) ) {
530 return $default;
531 } else {
532 return $this->settings[$name];
533 }
534 }
535
541 public function getCompiledDBs() {
542 return $this->compiledDBs;
543 }
544
552 public function getDBInstaller( $type = false ) {
553 if ( !$type ) {
554 $type = $this->getVar( 'wgDBtype' );
555 }
556
557 $type = strtolower( $type );
558
559 if ( !isset( $this->dbInstallers[$type] ) ) {
560 $class = ucfirst( $type ) . 'Installer';
561 $this->dbInstallers[$type] = new $class( $this );
562 }
563
564 return $this->dbInstallers[$type];
565 }
566
572 public static function getExistingLocalSettings() {
573 global $IP;
574
575 // You might be wondering why this is here. Well if you don't do this
576 // then some poorly-formed extensions try to call their own classes
577 // after immediately registering them. We really need to get extension
578 // registration out of the global scope and into a real format.
579 // @see https://phabricator.wikimedia.org/T69440
582
583 // @codingStandardsIgnoreStart
584 // LocalSettings.php should not call functions, except wfLoadSkin/wfLoadExtensions
585 // Define the required globals here, to ensure, the functions can do it work correctly.
587 // @codingStandardsIgnoreEnd
588
589 MediaWiki\suppressWarnings();
590 $_lsExists = file_exists( "$IP/LocalSettings.php" );
591 MediaWiki\restoreWarnings();
592
593 if ( !$_lsExists ) {
594 return false;
595 }
596 unset( $_lsExists );
597
598 require "$IP/includes/DefaultSettings.php";
599 require "$IP/LocalSettings.php";
600
601 return get_defined_vars();
602 }
603
613 public function getFakePassword( $realPassword ) {
614 return str_repeat( '*', strlen( $realPassword ) );
615 }
616
624 public function setPassword( $name, $value ) {
625 if ( !preg_match( '/^\*+$/', $value ) ) {
626 $this->setVar( $name, $value );
627 }
628 }
629
641 public static function maybeGetWebserverPrimaryGroup() {
642 if ( !function_exists( 'posix_getegid' ) || !function_exists( 'posix_getpwuid' ) ) {
643 # I don't know this, this isn't UNIX.
644 return null;
645 }
646
647 # posix_getegid() *not* getmygid() because we want the group of the webserver,
648 # not whoever owns the current script.
649 $gid = posix_getegid();
650 $group = posix_getpwuid( $gid )['name'];
651
652 return $group;
653 }
654
671 public function parse( $text, $lineStart = false ) {
673
674 try {
675 $out = $wgParser->parse( $text, $this->parserTitle, $this->parserOptions, $lineStart );
676 $html = $out->getText();
677 } catch ( DBAccessError $e ) {
678 $html = '<!--DB access attempted during parse--> ' . htmlspecialchars( $text );
679
680 if ( !empty( $this->debug ) ) {
681 $html .= "<!--\n" . $e->getTraceAsString() . "\n-->";
682 }
683 }
684
685 return $html;
686 }
687
691 public function getParserOptions() {
693 }
694
695 public function disableLinkPopups() {
696 $this->parserOptions->setExternalLinkTarget( false );
697 }
698
699 public function restoreLinkPopups() {
701 $this->parserOptions->setExternalLinkTarget( $wgExternalLinkTarget );
702 }
703
712 public function populateSiteStats( DatabaseInstaller $installer ) {
713 $status = $installer->getConnection();
714 if ( !$status->isOK() ) {
715 return $status;
716 }
717 $status->value->insert(
718 'site_stats',
719 [
720 'ss_row_id' => 1,
721 'ss_total_edits' => 0,
722 'ss_good_articles' => 0,
723 'ss_total_pages' => 0,
724 'ss_users' => 0,
725 'ss_images' => 0
726 ],
727 __METHOD__, 'IGNORE'
728 );
729
730 return Status::newGood();
731 }
732
737 protected function envCheckDB() {
739
740 $allNames = [];
741
742 // Messages: config-type-mysql, config-type-postgres, config-type-oracle,
743 // config-type-sqlite
744 foreach ( self::getDBTypes() as $name ) {
745 $allNames[] = wfMessage( "config-type-$name" )->text();
746 }
747
748 $databases = $this->getCompiledDBs();
749
750 $databases = array_flip( $databases );
751 foreach ( array_keys( $databases ) as $db ) {
752 $installer = $this->getDBInstaller( $db );
753 $status = $installer->checkPrerequisites();
754 if ( !$status->isGood() ) {
755 $this->showStatusMessage( $status );
756 }
757 if ( !$status->isOK() ) {
758 unset( $databases[$db] );
759 }
760 }
761 $databases = array_flip( $databases );
762 if ( !$databases ) {
763 $this->showError( 'config-no-db', $wgLang->commaList( $allNames ), count( $allNames ) );
764
765 // @todo FIXME: This only works for the web installer!
766 return false;
767 }
768
769 return true;
770 }
771
776 protected function envCheckBrokenXML() {
777 $test = new PhpXmlBugTester();
778 if ( !$test->ok ) {
779 $this->showError( 'config-brokenlibxml' );
780
781 return false;
782 }
783
784 return true;
785 }
786
795 protected function envCheckPCRE() {
796 MediaWiki\suppressWarnings();
797 $regexd = preg_replace( '/[\x{0430}-\x{04FF}]/iu', '', '-АБВГД-' );
798 // Need to check for \p support too, as PCRE can be compiled
799 // with utf8 support, but not unicode property support.
800 // check that \p{Zs} (space separators) matches
801 // U+3000 (Ideographic space)
802 $regexprop = preg_replace( '/\p{Zs}/u', '', "-\xE3\x80\x80-" );
803 MediaWiki\restoreWarnings();
804 if ( $regexd != '--' || $regexprop != '--' ) {
805 $this->showError( 'config-pcre-no-utf8' );
806
807 return false;
808 }
809
810 return true;
811 }
812
817 protected function envCheckMemory() {
818 $limit = ini_get( 'memory_limit' );
819
820 if ( !$limit || $limit == -1 ) {
821 return true;
822 }
823
825
826 if ( $n < $this->minMemorySize * 1024 * 1024 ) {
827 $newLimit = "{$this->minMemorySize}M";
828
829 if ( ini_set( "memory_limit", $newLimit ) === false ) {
830 $this->showMessage( 'config-memory-bad', $limit );
831 } else {
832 $this->showMessage( 'config-memory-raised', $limit, $newLimit );
833 $this->setVar( '_RaiseMemory', true );
834 }
835 }
836
837 return true;
838 }
839
843 protected function envCheckCache() {
844 $caches = [];
845 foreach ( $this->objectCaches as $name => $function ) {
846 if ( function_exists( $function ) ) {
847 if ( $name == 'xcache' && !wfIniGetBool( 'xcache.var_size' ) ) {
848 continue;
849 }
850 $caches[$name] = true;
851 }
852 }
853
854 if ( !$caches ) {
855 $key = 'config-no-cache-apcu';
856 $this->showMessage( $key );
857 }
858
859 $this->setVar( '_Caches', $caches );
860 }
861
866 protected function envCheckModSecurity() {
867 if ( self::apacheModulePresent( 'mod_security' )
868 || self::apacheModulePresent( 'mod_security2' ) ) {
869 $this->showMessage( 'config-mod-security' );
870 }
871
872 return true;
873 }
874
879 protected function envCheckDiff3() {
880 $names = [ "gdiff3", "diff3", "diff3.exe" ];
881 $versionInfo = [ '$1 --version 2>&1', 'GNU diffutils' ];
882
883 $diff3 = self::locateExecutableInDefaultPaths( $names, $versionInfo );
884
885 if ( $diff3 ) {
886 $this->setVar( 'wgDiff3', $diff3 );
887 } else {
888 $this->setVar( 'wgDiff3', false );
889 $this->showMessage( 'config-diff3-bad' );
890 }
891
892 return true;
893 }
894
899 protected function envCheckGraphics() {
900 $names = [ wfIsWindows() ? 'convert.exe' : 'convert' ];
901 $versionInfo = [ '$1 -version', 'ImageMagick' ];
902 $convert = self::locateExecutableInDefaultPaths( $names, $versionInfo );
903
904 $this->setVar( 'wgImageMagickConvertCommand', '' );
905 if ( $convert ) {
906 $this->setVar( 'wgImageMagickConvertCommand', $convert );
907 $this->showMessage( 'config-imagemagick', $convert );
908
909 return true;
910 } elseif ( function_exists( 'imagejpeg' ) ) {
911 $this->showMessage( 'config-gd' );
912 } else {
913 $this->showMessage( 'config-no-scaling' );
914 }
915
916 return true;
917 }
918
925 protected function envCheckGit() {
926 $names = [ wfIsWindows() ? 'git.exe' : 'git' ];
927 $versionInfo = [ '$1 --version', 'git version' ];
928
929 $git = self::locateExecutableInDefaultPaths( $names, $versionInfo );
930
931 if ( $git ) {
932 $this->setVar( 'wgGitBin', $git );
933 $this->showMessage( 'config-git', $git );
934 } else {
935 $this->setVar( 'wgGitBin', false );
936 $this->showMessage( 'config-git-bad' );
937 }
938
939 return true;
940 }
941
947 protected function envCheckServer() {
948 $server = $this->envGetDefaultServer();
949 if ( $server !== null ) {
950 $this->showMessage( 'config-using-server', $server );
951 }
952 return true;
953 }
954
960 protected function envCheckPath() {
961 $this->showMessage(
962 'config-using-uri',
963 $this->getVar( 'wgServer' ),
964 $this->getVar( 'wgScriptPath' )
965 );
966 return true;
967 }
968
973 protected function envCheckShellLocale() {
974 $os = php_uname( 's' );
975 $supported = [ 'Linux', 'SunOS', 'HP-UX', 'Darwin' ]; # Tested these
976
977 if ( !in_array( $os, $supported ) ) {
978 return true;
979 }
980
981 # Get a list of available locales.
982 $ret = false;
983 $lines = wfShellExec( '/usr/bin/locale -a', $ret );
984
985 if ( $ret ) {
986 return true;
987 }
988
989 $lines = array_map( 'trim', explode( "\n", $lines ) );
990 $candidatesByLocale = [];
991 $candidatesByLang = [];
992
993 foreach ( $lines as $line ) {
994 if ( $line === '' ) {
995 continue;
996 }
997
998 if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) {
999 continue;
1000 }
1001
1002 list( , $lang, , , ) = $m;
1003
1004 $candidatesByLocale[$m[0]] = $m;
1005 $candidatesByLang[$lang][] = $m;
1006 }
1007
1008 # Try the current value of LANG.
1009 if ( isset( $candidatesByLocale[getenv( 'LANG' )] ) ) {
1010 $this->setVar( 'wgShellLocale', getenv( 'LANG' ) );
1011
1012 return true;
1013 }
1014
1015 # Try the most common ones.
1016 $commonLocales = [ 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' ];
1017 foreach ( $commonLocales as $commonLocale ) {
1018 if ( isset( $candidatesByLocale[$commonLocale] ) ) {
1019 $this->setVar( 'wgShellLocale', $commonLocale );
1020
1021 return true;
1022 }
1023 }
1024
1025 # Is there an available locale in the Wiki's language?
1026 $wikiLang = $this->getVar( 'wgLanguageCode' );
1027
1028 if ( isset( $candidatesByLang[$wikiLang] ) ) {
1029 $m = reset( $candidatesByLang[$wikiLang] );
1030 $this->setVar( 'wgShellLocale', $m[0] );
1031
1032 return true;
1033 }
1034
1035 # Are there any at all?
1036 if ( count( $candidatesByLocale ) ) {
1037 $m = reset( $candidatesByLocale );
1038 $this->setVar( 'wgShellLocale', $m[0] );
1039
1040 return true;
1041 }
1042
1043 # Give up.
1044 return true;
1045 }
1046
1051 protected function envCheckUploadsDirectory() {
1052 global $IP;
1053
1054 $dir = $IP . '/images/';
1055 $url = $this->getVar( 'wgServer' ) . $this->getVar( 'wgScriptPath' ) . '/images/';
1056 $safe = !$this->dirIsExecutable( $dir, $url );
1057
1058 if ( !$safe ) {
1059 $this->showMessage( 'config-uploads-not-safe', $dir );
1060 }
1061
1062 return true;
1063 }
1064
1070 protected function envCheckSuhosinMaxValueLength() {
1071 $maxValueLength = ini_get( 'suhosin.get.max_value_length' );
1072 if ( $maxValueLength > 0 && $maxValueLength < 1024 ) {
1073 // Only warn if the value is below the sane 1024
1074 $this->showMessage( 'config-suhosin-max-value-length', $maxValueLength );
1075 }
1076
1077 return true;
1078 }
1079
1085 protected function unicodeChar( $c ) {
1086 $c = hexdec( $c );
1087 if ( $c <= 0x7F ) {
1088 return chr( $c );
1089 } elseif ( $c <= 0x7FF ) {
1090 return chr( 0xC0 | $c >> 6 ) . chr( 0x80 | $c & 0x3F );
1091 } elseif ( $c <= 0xFFFF ) {
1092 return chr( 0xE0 | $c >> 12 ) . chr( 0x80 | $c >> 6 & 0x3F ) .
1093 chr( 0x80 | $c & 0x3F );
1094 } elseif ( $c <= 0x10FFFF ) {
1095 return chr( 0xF0 | $c >> 18 ) . chr( 0x80 | $c >> 12 & 0x3F ) .
1096 chr( 0x80 | $c >> 6 & 0x3F ) .
1097 chr( 0x80 | $c & 0x3F );
1098 } else {
1099 return false;
1100 }
1101 }
1102
1106 protected function envCheckLibicu() {
1114 $not_normal_c = $this->unicodeChar( "FA6C" );
1115 $normal_c = $this->unicodeChar( "242EE" );
1116
1117 $useNormalizer = 'php';
1118 $needsUpdate = false;
1119
1120 if ( function_exists( 'normalizer_normalize' ) ) {
1121 $useNormalizer = 'intl';
1122 $intl = normalizer_normalize( $not_normal_c, Normalizer::FORM_C );
1123 if ( $intl !== $normal_c ) {
1124 $needsUpdate = true;
1125 }
1126 }
1127
1128 // Uses messages 'config-unicode-using-php' and 'config-unicode-using-intl'
1129 if ( $useNormalizer === 'php' ) {
1130 $this->showMessage( 'config-unicode-pure-php-warning' );
1131 } else {
1132 $this->showMessage( 'config-unicode-using-' . $useNormalizer );
1133 if ( $needsUpdate ) {
1134 $this->showMessage( 'config-unicode-update-warning' );
1135 }
1136 }
1137 }
1138
1142 protected function envPrepServer() {
1143 $server = $this->envGetDefaultServer();
1144 if ( $server !== null ) {
1145 $this->setVar( 'wgServer', $server );
1146 }
1147 }
1148
1153 abstract protected function envGetDefaultServer();
1154
1158 protected function envPrepPath() {
1159 global $IP;
1160 $IP = dirname( dirname( __DIR__ ) );
1161 $this->setVar( 'IP', $IP );
1162 }
1163
1171 protected static function getPossibleBinPaths() {
1172 return array_merge(
1173 [ '/usr/bin', '/usr/local/bin', '/opt/csw/bin',
1174 '/usr/gnu/bin', '/usr/sfw/bin', '/sw/bin', '/opt/local/bin' ],
1175 explode( PATH_SEPARATOR, getenv( 'PATH' ) )
1176 );
1177 }
1178
1196 public static function locateExecutable( $path, $names, $versionInfo = false ) {
1197 if ( !is_array( $names ) ) {
1198 $names = [ $names ];
1199 }
1200
1201 foreach ( $names as $name ) {
1202 $command = $path . DIRECTORY_SEPARATOR . $name;
1203
1204 MediaWiki\suppressWarnings();
1205 $file_exists = is_executable( $command );
1206 MediaWiki\restoreWarnings();
1207
1208 if ( $file_exists ) {
1209 if ( !$versionInfo ) {
1210 return $command;
1211 }
1212
1213 $file = str_replace( '$1', wfEscapeShellArg( $command ), $versionInfo[0] );
1214 if ( strstr( wfShellExec( $file ), $versionInfo[1] ) !== false ) {
1215 return $command;
1216 }
1217 }
1218 }
1219
1220 return false;
1221 }
1222
1235 public static function locateExecutableInDefaultPaths( $names, $versionInfo = false ) {
1236 foreach ( self::getPossibleBinPaths() as $path ) {
1237 $exe = self::locateExecutable( $path, $names, $versionInfo );
1238 if ( $exe !== false ) {
1239 return $exe;
1240 }
1241 }
1242
1243 return false;
1244 }
1245
1254 public function dirIsExecutable( $dir, $url ) {
1255 $scriptTypes = [
1256 'php' => [
1257 "<?php echo 'ex' . 'ec';",
1258 "#!/var/env php5\n<?php echo 'ex' . 'ec';",
1259 ],
1260 ];
1261
1262 // it would be good to check other popular languages here, but it'll be slow.
1263
1264 MediaWiki\suppressWarnings();
1265
1266 foreach ( $scriptTypes as $ext => $contents ) {
1267 foreach ( $contents as $source ) {
1268 $file = 'exectest.' . $ext;
1269
1270 if ( !file_put_contents( $dir . $file, $source ) ) {
1271 break;
1272 }
1273
1274 try {
1275 $text = Http::get( $url . $file, [ 'timeout' => 3 ], __METHOD__ );
1276 } catch ( Exception $e ) {
1277 // Http::get throws with allow_url_fopen = false and no curl extension.
1278 $text = null;
1279 }
1280 unlink( $dir . $file );
1281
1282 if ( $text == 'exec' ) {
1283 MediaWiki\restoreWarnings();
1284
1285 return $ext;
1286 }
1287 }
1288 }
1289
1290 MediaWiki\restoreWarnings();
1291
1292 return false;
1293 }
1294
1301 public static function apacheModulePresent( $moduleName ) {
1302 if ( function_exists( 'apache_get_modules' ) && in_array( $moduleName, apache_get_modules() ) ) {
1303 return true;
1304 }
1305 // try it the hard way
1306 ob_start();
1307 phpinfo( INFO_MODULES );
1308 $info = ob_get_clean();
1309
1310 return strpos( $info, $moduleName ) !== false;
1311 }
1312
1318 public function setParserLanguage( $lang ) {
1319 $this->parserOptions->setTargetLanguage( $lang );
1320 $this->parserOptions->setUserLang( $lang );
1321 }
1322
1328 protected function getDocUrl( $page ) {
1329 return "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
1330 }
1331
1341 public function findExtensions( $directory = 'extensions' ) {
1342 if ( $this->getVar( 'IP' ) === null ) {
1343 return [];
1344 }
1345
1346 $extDir = $this->getVar( 'IP' ) . '/' . $directory;
1347 if ( !is_readable( $extDir ) || !is_dir( $extDir ) ) {
1348 return [];
1349 }
1350
1351 // extensions -> extension.json, skins -> skin.json
1352 $jsonFile = substr( $directory, 0, strlen( $directory ) -1 ) . '.json';
1353
1354 $dh = opendir( $extDir );
1355 $exts = [];
1356 while ( ( $file = readdir( $dh ) ) !== false ) {
1357 if ( !is_dir( "$extDir/$file" ) ) {
1358 continue;
1359 }
1360 if ( file_exists( "$extDir/$file/$jsonFile" ) || file_exists( "$extDir/$file/$file.php" ) ) {
1361 $exts[] = $file;
1362 }
1363 }
1364 closedir( $dh );
1365 natcasesort( $exts );
1366
1367 return $exts;
1368 }
1369
1378 public function getDefaultSkin( array $skinNames ) {
1379 $defaultSkin = $GLOBALS['wgDefaultSkin'];
1380 if ( !$skinNames || in_array( $defaultSkin, $skinNames ) ) {
1381 return $defaultSkin;
1382 } else {
1383 return $skinNames[0];
1384 }
1385 }
1386
1392 protected function includeExtensions() {
1393 global $IP;
1394 $exts = $this->getVar( '_Extensions' );
1395 $IP = $this->getVar( 'IP' );
1396
1406 $wgAutoloadClasses = [];
1407 $queue = [];
1408
1409 require "$IP/includes/DefaultSettings.php";
1410
1411 foreach ( $exts as $e ) {
1412 if ( file_exists( "$IP/extensions/$e/extension.json" ) ) {
1413 $queue["$IP/extensions/$e/extension.json"] = 1;
1414 } else {
1415 require_once "$IP/extensions/$e/$e.php";
1416 }
1417 }
1418
1419 $registry = new ExtensionRegistry();
1420 $data = $registry->readFromQueue( $queue );
1421 $wgAutoloadClasses += $data['autoload'];
1422
1423 $hooksWeWant = isset( $wgHooks['LoadExtensionSchemaUpdates'] ) ?
1424 $wgHooks['LoadExtensionSchemaUpdates'] : [];
1425
1426 if ( isset( $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {
1427 $hooksWeWant = array_merge_recursive(
1428 $hooksWeWant,
1429 $data['globals']['wgHooks']['LoadExtensionSchemaUpdates']
1430 );
1431 }
1432 // Unset everyone else's hooks. Lord knows what someone might be doing
1433 // in ParserFirstCallInit (see bug 27171)
1434 $GLOBALS['wgHooks'] = [ 'LoadExtensionSchemaUpdates' => $hooksWeWant ];
1435
1436 return Status::newGood();
1437 }
1438
1451 protected function getInstallSteps( DatabaseInstaller $installer ) {
1452 $coreInstallSteps = [
1453 [ 'name' => 'database', 'callback' => [ $installer, 'setupDatabase' ] ],
1454 [ 'name' => 'tables', 'callback' => [ $installer, 'createTables' ] ],
1455 [ 'name' => 'interwiki', 'callback' => [ $installer, 'populateInterwikiTable' ] ],
1456 [ 'name' => 'stats', 'callback' => [ $this, 'populateSiteStats' ] ],
1457 [ 'name' => 'keys', 'callback' => [ $this, 'generateKeys' ] ],
1458 [ 'name' => 'updates', 'callback' => [ $installer, 'insertUpdateKeys' ] ],
1459 [ 'name' => 'sysop', 'callback' => [ $this, 'createSysop' ] ],
1460 [ 'name' => 'mainpage', 'callback' => [ $this, 'createMainpage' ] ],
1461 ];
1462
1463 // Build the array of install steps starting from the core install list,
1464 // then adding any callbacks that wanted to attach after a given step
1465 foreach ( $coreInstallSteps as $step ) {
1466 $this->installSteps[] = $step;
1467 if ( isset( $this->extraInstallSteps[$step['name']] ) ) {
1468 $this->installSteps = array_merge(
1469 $this->installSteps,
1470 $this->extraInstallSteps[$step['name']]
1471 );
1472 }
1473 }
1474
1475 // Prepend any steps that want to be at the beginning
1476 if ( isset( $this->extraInstallSteps['BEGINNING'] ) ) {
1477 $this->installSteps = array_merge(
1478 $this->extraInstallSteps['BEGINNING'],
1479 $this->installSteps
1480 );
1481 }
1482
1483 // Extensions should always go first, chance to tie into hooks and such
1484 if ( count( $this->getVar( '_Extensions' ) ) ) {
1485 array_unshift( $this->installSteps,
1486 [ 'name' => 'extensions', 'callback' => [ $this, 'includeExtensions' ] ]
1487 );
1488 $this->installSteps[] = [
1489 'name' => 'extension-tables',
1490 'callback' => [ $installer, 'createExtensionTables' ]
1491 ];
1492 }
1493
1494 return $this->installSteps;
1495 }
1496
1505 public function performInstallation( $startCB, $endCB ) {
1506 $installResults = [];
1507 $installer = $this->getDBInstaller();
1508 $installer->preInstall();
1509 $steps = $this->getInstallSteps( $installer );
1510 foreach ( $steps as $stepObj ) {
1511 $name = $stepObj['name'];
1512 call_user_func_array( $startCB, [ $name ] );
1513
1514 // Perform the callback step
1515 $status = call_user_func( $stepObj['callback'], $installer );
1516
1517 // Output and save the results
1518 call_user_func( $endCB, $name, $status );
1519 $installResults[$name] = $status;
1520
1521 // If we've hit some sort of fatal, we need to bail.
1522 // Callback already had a chance to do output above.
1523 if ( !$status->isOk() ) {
1524 break;
1525 }
1526 }
1527 if ( $status->isOk() ) {
1528 $this->setVar( '_InstallDone', true );
1529 }
1530
1531 return $installResults;
1532 }
1533
1539 public function generateKeys() {
1540 $keys = [ 'wgSecretKey' => 64 ];
1541 if ( strval( $this->getVar( 'wgUpgradeKey' ) ) === '' ) {
1542 $keys['wgUpgradeKey'] = 16;
1543 }
1544
1545 return $this->doGenerateKeys( $keys );
1546 }
1547
1555 protected function doGenerateKeys( $keys ) {
1556 $status = Status::newGood();
1557
1558 $strong = true;
1559 foreach ( $keys as $name => $length ) {
1560 $secretKey = MWCryptRand::generateHex( $length, true );
1561 if ( !MWCryptRand::wasStrong() ) {
1562 $strong = false;
1563 }
1564
1565 $this->setVar( $name, $secretKey );
1566 }
1567
1568 if ( !$strong ) {
1569 $names = array_keys( $keys );
1570 $names = preg_replace( '/^(.*)$/', '\$$1', $names );
1572 $status->warning( 'config-insecure-keys', $wgLang->listToText( $names ), count( $names ) );
1573 }
1574
1575 return $status;
1576 }
1577
1583 protected function createSysop() {
1584 $name = $this->getVar( '_AdminName' );
1585 $user = User::newFromName( $name );
1586
1587 if ( !$user ) {
1588 // We should've validated this earlier anyway!
1589 return Status::newFatal( 'config-admin-error-user', $name );
1590 }
1591
1592 if ( $user->idForName() == 0 ) {
1593 $user->addToDatabase();
1594
1595 try {
1596 $user->setPassword( $this->getVar( '_AdminPassword' ) );
1597 } catch ( PasswordError $pwe ) {
1598 return Status::newFatal( 'config-admin-error-password', $name, $pwe->getMessage() );
1599 }
1600
1601 $user->addGroup( 'sysop' );
1602 $user->addGroup( 'bureaucrat' );
1603 if ( $this->getVar( '_AdminEmail' ) ) {
1604 $user->setEmail( $this->getVar( '_AdminEmail' ) );
1605 }
1606 $user->saveSettings();
1607
1608 // Update user count
1609 $ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
1610 $ssUpdate->doUpdate();
1611 }
1612 $status = Status::newGood();
1613
1614 if ( $this->getVar( '_Subscribe' ) && $this->getVar( '_AdminEmail' ) ) {
1616 }
1617
1618 return $status;
1619 }
1620
1625 $params = [
1626 'email' => $this->getVar( '_AdminEmail' ),
1627 'language' => 'en',
1628 'digest' => 0
1629 ];
1630
1631 // Mailman doesn't support as many languages as we do, so check to make
1632 // sure their selected language is available
1633 $myLang = $this->getVar( '_UserLang' );
1634 if ( in_array( $myLang, $this->mediaWikiAnnounceLanguages ) ) {
1635 $myLang = $myLang == 'pt-br' ? 'pt_BR' : $myLang; // rewrite to Mailman's pt_BR
1636 $params['language'] = $myLang;
1637 }
1638
1639 if ( MWHttpRequest::canMakeRequests() ) {
1640 $res = MWHttpRequest::factory( $this->mediaWikiAnnounceUrl,
1641 [ 'method' => 'POST', 'postData' => $params ], __METHOD__ )->execute();
1642 if ( !$res->isOK() ) {
1643 $s->warning( 'config-install-subscribe-fail', $res->getMessage() );
1644 }
1645 } else {
1646 $s->warning( 'config-install-subscribe-notpossible' );
1647 }
1648 }
1649
1656 protected function createMainpage( DatabaseInstaller $installer ) {
1657 $status = Status::newGood();
1658 try {
1659 $page = WikiPage::factory( Title::newMainPage() );
1661 wfMessage( 'mainpagetext' )->inContentLanguage()->text() . "\n\n" .
1662 wfMessage( 'mainpagedocfooter' )->inContentLanguage()->text()
1663 );
1664
1665 $status = $page->doEditContent( $content,
1666 '',
1667 EDIT_NEW,
1668 false,
1669 User::newFromName( 'MediaWiki default' )
1670 );
1671 } catch ( Exception $e ) {
1672 // using raw, because $wgShowExceptionDetails can not be set yet
1673 $status->fatal( 'config-install-mainpage-failed', $e->getMessage() );
1674 }
1675
1676 return $status;
1677 }
1678
1682 public static function overrideConfig() {
1683 // Use PHP's built-in session handling, since MediaWiki's
1684 // SessionHandler can't work before we have an object cache set up.
1685 define( 'MW_NO_SESSION_HANDLER', 1 );
1686
1687 // Don't access the database
1688 $GLOBALS['wgUseDatabaseMessages'] = false;
1689 // Don't cache langconv tables
1690 $GLOBALS['wgLanguageConverterCacheType'] = CACHE_NONE;
1691 // Debug-friendly
1692 $GLOBALS['wgShowExceptionDetails'] = true;
1693 // Don't break forms
1694 $GLOBALS['wgExternalLinkTarget'] = '_blank';
1695
1696 // Extended debugging
1697 $GLOBALS['wgShowSQLErrors'] = true;
1698 $GLOBALS['wgShowDBErrorBacktrace'] = true;
1699
1700 // Allow multiple ob_flush() calls
1701 $GLOBALS['wgDisableOutputCompression'] = true;
1702
1703 // Use a sensible cookie prefix (not my_wiki)
1704 $GLOBALS['wgCookiePrefix'] = 'mw_installer';
1705
1706 // Some of the environment checks make shell requests, remove limits
1707 $GLOBALS['wgMaxShellMemory'] = 0;
1708
1709 // Override the default CookieSessionProvider with a dummy
1710 // implementation that won't stomp on PHP's cookies.
1711 $GLOBALS['wgSessionProviders'] = [
1712 [
1713 'class' => 'InstallerSessionProvider',
1714 'args' => [ [
1715 'priority' => 1,
1716 ] ]
1717 ]
1718 ];
1719
1720 // Don't try to use any object cache for SessionManager either.
1721 $GLOBALS['wgSessionCacheType'] = CACHE_NONE;
1722 }
1723
1731 public function addInstallStep( $callback, $findStep = 'BEGINNING' ) {
1732 $this->extraInstallSteps[$findStep][] = $callback;
1733 }
1734
1739 protected function disableTimeLimit() {
1740 MediaWiki\suppressWarnings();
1741 set_time_limit( 0 );
1742 MediaWiki\restoreWarnings();
1743 }
1744}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$GLOBALS['IP']
$wgObjectCaches
Advanced object cache configuration.
$wgStyleDirectory
Filesystem stylesheets directory.
$wgAutoloadClasses
Array mapping class names to filenames, for autoloading.
$wgExtensionDirectory
Filesystem extensions directory.
$wgExternalLinkTarget
Set a default target for external links, e.g.
wfIniGetBool( $setting)
Safety wrapper around ini_get() for boolean settings.
wfShellExec( $cmd, &$retval=null, $environ=[], $limits=[], $options=[])
Execute a shell command, with time and memory limits mirrored from the PHP configuration if supported...
wfEscapeShellArg()
Version of escapeshellarg() that works better on Windows.
wfIsWindows()
Check if the operating system is Windows.
wfShorthandToInteger( $string='', $default=-1)
Converts shorthand byte notation to integer form.
wfIsHHVM()
Check if we are running under HHVM.
$wgUser
Definition Setup.php:806
$wgParser
Definition Setup.php:821
$IP
Definition WebStart.php:58
$line
Definition cdb.php:59
$command
Definition cdb.php:65
Exception class for attempted DB access.
Base class for DBMS-specific installation helper classes.
getConnection()
Connect to the database using the administrative user/password currently defined in the session.
ExtensionRegistry class.
Accesses configuration settings from $GLOBALS.
A Config instance which stores all settings as a member variable.
Base installer class.
Definition Installer.php:43
envPrepServer()
Environment prep for the server hostname.
static locateExecutable( $path, $names, $versionInfo=false)
Search a path for any of the given executable names.
parse( $text, $lineStart=false)
Convert wikitext $text to HTML.
array $compiledDBs
List of detected DBs, access using getCompiledDBs().
Definition Installer.php:63
Title $parserTitle
Cached Title, used by parse().
Definition Installer.php:84
includeExtensions()
Installs the auto-detected extensions.
createMainpage(DatabaseInstaller $installer)
Insert Main Page with default content.
const MINIMUM_PCRE_VERSION
The oldest version of PCRE we can support.
Definition Installer.php:51
getDefaultSkin(array $skinNames)
Returns a default value to be used for $wgDefaultSkin: normally the one set in DefaultSettings,...
envCheckLibicu()
Check the libicu version.
getDBInstaller( $type=false)
Get an instance of DatabaseInstaller for the specified DB type.
envCheckDB()
Environment check for DB types.
envCheckSuhosinMaxValueLength()
Checks if suhosin.get.max_value_length is set, and if so generate a warning because it decreases Reso...
setVar( $name, $value)
Set a MW configuration variable, or internal installer configuration variable.
array $internalDefaults
Variables that are stored alongside globals, and are used for any configuration of the installation p...
envCheckModSecurity()
Scare user to death if they have mod_security or mod_security2.
getFakePassword( $realPassword)
Get a fake password for sending back to the user in HTML.
envCheckServer()
Environment check to inform user which server we've assumed.
disableTimeLimit()
Disable the time limit for execution.
$mediaWikiAnnounceUrl
URL to mediawiki-announce subscription.
static apacheModulePresent( $moduleName)
Checks for presence of an Apache module.
array $rightsProfiles
User rights profiles.
addInstallStep( $callback, $findStep='BEGINNING')
Add an installation step following the given step.
getParserOptions()
getCompiledDBs()
Get a list of DBs supported by current PHP setup.
envCheckBrokenXML()
Some versions of libxml+PHP break < and > encoding horribly.
array $installSteps
The actual list of installation steps.
ParserOptions $parserOptions
Cached ParserOptions, used by parse().
Definition Installer.php:91
static locateExecutableInDefaultPaths( $names, $versionInfo=false)
Same as locateExecutable(), but checks in getPossibleBinPaths() by default.
dirIsExecutable( $dir, $url)
Checks if scripts located in the given directory can be executed via the given URL.
doEnvironmentPreps()
envCheckGit()
Search for git.
getDocUrl( $page)
Overridden by WebInstaller to provide lastPage parameters.
array $defaultVarNames
MediaWiki configuration globals that will eventually be passed through to LocalSettings....
showMessage( $msg)
UI interface for displaying a short message The parameters are like parameters to wfMessage().
static getExistingLocalSettings()
Determine if LocalSettings.php exists.
showError( $msg)
Same as showMessage(), but for displaying errors.
static getInstallerConfig(Config $baseConfig)
Constructs a Config object that contains configuration settings that should be overwritten for the in...
array $settings
Definition Installer.php:56
static getPossibleBinPaths()
Get an array of likely places we can find executables.
envCheckMemory()
Environment check for available memory.
array $objectCaches
Known object cache types and the functions used to test for their existence.
array $licenses
License types.
static maybeGetWebserverPrimaryGroup()
On POSIX systems return the primary group of the webserver we're running under.
doEnvironmentChecks()
Do initial checks of the PHP environment.
disableLinkPopups()
performInstallation( $startCB, $endCB)
Actually perform the installation.
generateKeys()
Generate $wgSecretKey.
populateSiteStats(DatabaseInstaller $installer)
Install step which adds a row to the site_stats table with appropriate initial values.
subscribeToMediaWikiAnnounce(Status $s)
envCheckCache()
Environment check for compiled object cache types.
__construct()
Constructor, always call this from child classes.
int $minMemorySize
Minimum memory size in MB.
Definition Installer.php:77
doGenerateKeys( $keys)
Generate a secret value for variables using our CryptRand generator.
showStatusMessage(Status $status)
Show a message to the installing user by using a Status object.
envCheckPath()
Environment check to inform user which paths we've assumed.
array $envPreps
A list of environment preparation methods called by doEnvironmentPreps().
$mediaWikiAnnounceLanguages
Supported language codes for Mailman.
setPassword( $name, $value)
Set a variable which stores a password, except if the new value is a fake password in which case leav...
envPrepPath()
Environment prep for setting $IP and $wgScriptPath.
static getDBTypes()
Get a list of known DB types.
createSysop()
Create the first user account, grant it sysop and bureaucrat rights.
envCheckPCRE()
Environment check for the PCRE module.
getVar( $name, $default=null)
Get an MW configuration variable, or internal installer configuration variable.
static overrideConfig()
Override the necessary bits of the config to run an installation.
restoreLinkPopups()
array $extraInstallSteps
Extra steps for installation, for things like DatabaseInstallers to modify.
static array $dbTypes
Known database types.
envCheckDiff3()
Search for GNU diff3.
envCheckShellLocale()
Environment check for preferred locale in shell.
envGetDefaultServer()
Helper function to be called from envPrepServer()
getInstallSteps(DatabaseInstaller $installer)
Get an array of install steps.
array $dbInstallers
Cached DB installer instances, access using getDBInstaller().
Definition Installer.php:70
array $envChecks
A list of environment check methods called by doEnvironmentChecks().
envCheckGraphics()
Environment check for ImageMagick and GD.
unicodeChar( $c)
Convert a hex string representing a Unicode code point to that code point.
envCheckUploadsDirectory()
Environment check for the permissions of the uploads directory.
setParserLanguage( $lang)
ParserOptions are constructed before we determined the language, so fix it.
findExtensions( $directory='extensions')
Finds extensions that follow the format /$directory/Name/Name.php, and returns an array containing th...
static wasStrong()
Return a boolean indicating whether or not the source used for cryptographic random bytes generation ...
static generateHex( $chars, $forceStrong=false)
Generate a run of (ideally) cryptographically random data and return it in hexadecimal string format.
MediaWikiServices is the service locator for the application scope of MediaWiki.
Provides a fallback sequence for Config objects.
Set options of the Parser.
Show an error when any operation involving passwords fails to run.
Test for PHP+libxml2 bug which breaks XML input subtly with certain versions.
static getMain()
Static methods.
Class for handling updates to the site_stats table.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition Status.php:40
Represents a title within MediaWiki.
Definition Title.php:36
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition WikiPage.php:115
Content object for wiki text pages.
$res
Definition database.txt:21
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition deferred.txt:11
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition design.txt:18
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
Definition design.txt:56
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration settings
Definition globals.txt:37
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest to get request data $wgMemc
Definition globals.txt:66
const CACHE_NONE
Definition Defines.php:94
const CACHE_ANYTHING
Definition Defines.php:93
const CACHE_MEMCACHED
Definition Defines.php:96
const CACHE_DB
Definition Defines.php:95
const EDIT_NEW
Definition Defines.php:146
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Definition hooks.txt:1049
the array() calling protocol came about after MediaWiki 1.4rc1.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
Definition hooks.txt:249
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition hooks.txt:2568
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content $content
Definition hooks.txt:1094
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt;div ...>$1&lt;/div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive $limit
Definition hooks.txt:1135
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition hooks.txt:1949
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition hooks.txt:886
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
Definition hooks.txt:1957
$wgHooks['ArticleShow'][]
Definition hooks.txt:110
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:304
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
Definition hooks.txt:2534
processing should stop and the error should be shown to the user * false
Definition hooks.txt:189
returning false will NOT prevent logging $e
Definition hooks.txt:2110
if(count( $args)==0) $dir
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
Interface for configuration instances.
Definition Config.php:28
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
$source
$lines
Definition router.php:67
$params
if(!isset( $args[0])) $lang