MediaWiki  1.27.2
Installer.php
Go to the documentation of this file.
1 <?php
42 abstract class Installer {
43 
50  const MINIMUM_PCRE_VERSION = '7.2';
51 
55  protected $settings;
56 
62  protected $compiledDBs;
63 
69  protected $dbInstallers = [];
70 
76  protected $minMemorySize = 50;
77 
83  protected $parserTitle;
84 
90  protected $parserOptions;
91 
101  protected static $dbTypes = [
102  'mysql',
103  'postgres',
104  'oracle',
105  'mssql',
106  'sqlite',
107  ];
108 
120  protected $envChecks = [
121  'envCheckDB',
122  'envCheckBrokenXML',
123  'envCheckPCRE',
124  'envCheckMemory',
125  'envCheckCache',
126  'envCheckModSecurity',
127  'envCheckDiff3',
128  'envCheckGraphics',
129  'envCheckGit',
130  'envCheckServer',
131  'envCheckPath',
132  'envCheckShellLocale',
133  'envCheckUploadsDirectory',
134  'envCheckLibicu',
135  'envCheckSuhosinMaxValueLength',
136  ];
137 
143  protected $envPreps = [
144  'envPrepServer',
145  'envPrepPath',
146  ];
147 
155  protected $defaultVarNames = [
156  'wgSitename',
157  'wgPasswordSender',
158  'wgLanguageCode',
159  'wgRightsIcon',
160  'wgRightsText',
161  'wgRightsUrl',
162  'wgEnableEmail',
163  'wgEnableUserEmail',
164  'wgEnotifUserTalk',
165  'wgEnotifWatchlist',
166  'wgEmailAuthentication',
167  'wgDBname',
168  'wgDBtype',
169  'wgDiff3',
170  'wgImageMagickConvertCommand',
171  'wgGitBin',
172  'IP',
173  'wgScriptPath',
174  'wgMetaNamespace',
175  'wgDeletedDirectory',
176  'wgEnableUploads',
177  'wgShellLocale',
178  'wgSecretKey',
179  'wgUseInstantCommons',
180  'wgUpgradeKey',
181  'wgDefaultSkin',
182  ];
183 
191  protected $internalDefaults = [
192  '_UserLang' => 'en',
193  '_Environment' => false,
194  '_RaiseMemory' => false,
195  '_UpgradeDone' => false,
196  '_InstallDone' => false,
197  '_Caches' => [],
198  '_InstallPassword' => '',
199  '_SameAccount' => true,
200  '_CreateDBAccount' => false,
201  '_NamespaceType' => 'site-name',
202  '_AdminName' => '', // will be set later, when the user selects language
203  '_AdminPassword' => '',
204  '_AdminPasswordConfirm' => '',
205  '_AdminEmail' => '',
206  '_Subscribe' => false,
207  '_SkipOptional' => 'continue',
208  '_RightsProfile' => 'wiki',
209  '_LicenseCode' => 'none',
210  '_CCDone' => false,
211  '_Extensions' => [],
212  '_Skins' => [],
213  '_MemCachedServers' => '',
214  '_UpgradeKeySupplied' => false,
215  '_ExistingDBSettings' => false,
216 
217  // $wgLogo is probably wrong (bug 48084); set something that will work.
218  // Single quotes work fine here, as LocalSettingsGenerator outputs this unescaped.
219  'wgLogo' => '$wgResourceBasePath/resources/assets/wiki.png',
220  'wgAuthenticationTokenVersion' => 1,
221  ];
222 
228  private $installSteps = [];
229 
235  protected $extraInstallSteps = [];
236 
242  protected $objectCaches = [
243  'xcache' => 'xcache_get',
244  'apc' => 'apc_fetch',
245  'apcu' => 'apcu_fetch',
246  'wincache' => 'wincache_ucache_get'
247  ];
248 
254  public $rightsProfiles = [
255  'wiki' => [],
256  'no-anon' => [
257  '*' => [ 'edit' => false ]
258  ],
259  'fishbowl' => [
260  '*' => [
261  'createaccount' => false,
262  'edit' => false,
263  ],
264  ],
265  'private' => [
266  '*' => [
267  'createaccount' => false,
268  'edit' => false,
269  'read' => false,
270  ],
271  ],
272  ];
273 
279  public $licenses = [
280  'cc-by' => [
281  'url' => 'https://creativecommons.org/licenses/by/4.0/',
282  'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-by.png',
283  ],
284  'cc-by-sa' => [
285  'url' => 'https://creativecommons.org/licenses/by-sa/4.0/',
286  'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-by-sa.png',
287  ],
288  'cc-by-nc-sa' => [
289  'url' => 'https://creativecommons.org/licenses/by-nc-sa/4.0/',
290  'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-by-nc-sa.png',
291  ],
292  'cc-0' => [
293  'url' => 'https://creativecommons.org/publicdomain/zero/1.0/',
294  'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-0.png',
295  ],
296  'pd' => [
297  'url' => '',
298  'icon' => '$wgResourceBasePath/resources/assets/licenses/public-domain.png',
299  ],
300  'gfdl' => [
301  'url' => 'https://www.gnu.org/copyleft/fdl.html',
302  'icon' => '$wgResourceBasePath/resources/assets/licenses/gnu-fdl.png',
303  ],
304  'none' => [
305  'url' => '',
306  'icon' => '',
307  'text' => ''
308  ],
309  'cc-choose' => [
310  // Details will be filled in by the selector.
311  'url' => '',
312  'icon' => '',
313  'text' => '',
314  ],
315  ];
316 
321  'https://lists.wikimedia.org/mailman/subscribe/mediawiki-announce';
322 
327  'ca', 'cs', 'da', 'de', 'en', 'es', 'et', 'eu', 'fi', 'fr', 'hr', 'hu',
328  'it', 'ja', 'ko', 'lt', 'nl', 'no', 'pl', 'pt', 'pt-br', 'ro', 'ru',
329  'sl', 'sr', 'sv', 'tr', 'uk'
330  ];
331 
339  abstract public function showMessage( $msg /*, ... */ );
340 
345  abstract public function showError( $msg /*, ... */ );
346 
351  abstract public function showStatusMessage( Status $status );
352 
356  public function __construct() {
357  global $wgMessagesDirs, $wgUser;
358 
359  // Don't attempt to load user language options (T126177)
360  // This will be overridden in the web installer with the user-specified language
361  RequestContext::getMain()->setLanguage( 'en' );
362 
363  // Disable the i18n cache
364  Language::getLocalisationCache()->disableBackend();
365  // Disable LoadBalancer and wfGetDB etc.
367 
368  // Disable object cache (otherwise CACHE_ANYTHING will try CACHE_DB and
369  // SqlBagOStuff will then throw since we just disabled wfGetDB)
370  $GLOBALS['wgMemc'] = new EmptyBagOStuff;
372  $emptyCache = [ 'class' => 'EmptyBagOStuff' ];
373  // disable (problematic) object cache types explicitly, preserving all other (working) ones
374  // bug T113843
375  $GLOBALS['wgObjectCaches'] = [
376  CACHE_NONE => $emptyCache,
377  CACHE_DB => $emptyCache,
378  CACHE_ANYTHING => $emptyCache,
379  CACHE_MEMCACHED => $emptyCache,
380  ] + $GLOBALS['wgObjectCaches'];
381 
382  // Load the installer's i18n.
383  $wgMessagesDirs['MediawikiInstaller'] = __DIR__ . '/i18n';
384 
385  // Having a user with id = 0 safeguards us from DB access via User::loadOptions().
386  $wgUser = User::newFromId( 0 );
387  RequestContext::getMain()->setUser( $wgUser );
388 
390 
391  foreach ( $this->defaultVarNames as $var ) {
392  $this->settings[$var] = $GLOBALS[$var];
393  }
394 
395  $this->doEnvironmentPreps();
396 
397  $this->compiledDBs = [];
398  foreach ( self::getDBTypes() as $type ) {
399  $installer = $this->getDBInstaller( $type );
400 
401  if ( !$installer->isCompiled() ) {
402  continue;
403  }
404  $this->compiledDBs[] = $type;
405  }
406 
407  $this->parserTitle = Title::newFromText( 'Installer' );
408  $this->parserOptions = new ParserOptions( $wgUser ); // language will be wrong :(
409  $this->parserOptions->setEditSection( false );
410  }
411 
417  public static function getDBTypes() {
418  return self::$dbTypes;
419  }
420 
434  public function doEnvironmentChecks() {
435  // Php version has already been checked by entry scripts
436  // Show message here for information purposes
437  if ( wfIsHHVM() ) {
438  $this->showMessage( 'config-env-hhvm', HHVM_VERSION );
439  } else {
440  $this->showMessage( 'config-env-php', PHP_VERSION );
441  }
442 
443  $good = true;
444  // Must go here because an old version of PCRE can prevent other checks from completing
445  list( $pcreVersion ) = explode( ' ', PCRE_VERSION, 2 );
446  if ( version_compare( $pcreVersion, self::MINIMUM_PCRE_VERSION, '<' ) ) {
447  $this->showError( 'config-pcre-old', self::MINIMUM_PCRE_VERSION, $pcreVersion );
448  $good = false;
449  } else {
450  foreach ( $this->envChecks as $check ) {
451  $status = $this->$check();
452  if ( $status === false ) {
453  $good = false;
454  }
455  }
456  }
457 
458  $this->setVar( '_Environment', $good );
459 
460  return $good ? Status::newGood() : Status::newFatal( 'config-env-bad' );
461  }
462 
463  public function doEnvironmentPreps() {
464  foreach ( $this->envPreps as $prep ) {
465  $this->$prep();
466  }
467  }
468 
475  public function setVar( $name, $value ) {
476  $this->settings[$name] = $value;
477  }
478 
489  public function getVar( $name, $default = null ) {
490  if ( !isset( $this->settings[$name] ) ) {
491  return $default;
492  } else {
493  return $this->settings[$name];
494  }
495  }
496 
502  public function getCompiledDBs() {
503  return $this->compiledDBs;
504  }
505 
513  public function getDBInstaller( $type = false ) {
514  if ( !$type ) {
515  $type = $this->getVar( 'wgDBtype' );
516  }
517 
518  $type = strtolower( $type );
519 
520  if ( !isset( $this->dbInstallers[$type] ) ) {
521  $class = ucfirst( $type ) . 'Installer';
522  $this->dbInstallers[$type] = new $class( $this );
523  }
524 
525  return $this->dbInstallers[$type];
526  }
527 
533  public static function getExistingLocalSettings() {
534  global $IP;
535 
536  // You might be wondering why this is here. Well if you don't do this
537  // then some poorly-formed extensions try to call their own classes
538  // after immediately registering them. We really need to get extension
539  // registration out of the global scope and into a real format.
540  // @see https://phabricator.wikimedia.org/T69440
542  $wgAutoloadClasses = [];
543 
544  // @codingStandardsIgnoreStart
545  // LocalSettings.php should not call functions, except wfLoadSkin/wfLoadExtensions
546  // Define the required globals here, to ensure, the functions can do it work correctly.
548  // @codingStandardsIgnoreEnd
549 
550  MediaWiki\suppressWarnings();
551  $_lsExists = file_exists( "$IP/LocalSettings.php" );
552  MediaWiki\restoreWarnings();
553 
554  if ( !$_lsExists ) {
555  return false;
556  }
557  unset( $_lsExists );
558 
559  require "$IP/includes/DefaultSettings.php";
560  require "$IP/LocalSettings.php";
561 
562  return get_defined_vars();
563  }
564 
574  public function getFakePassword( $realPassword ) {
575  return str_repeat( '*', strlen( $realPassword ) );
576  }
577 
585  public function setPassword( $name, $value ) {
586  if ( !preg_match( '/^\*+$/', $value ) ) {
587  $this->setVar( $name, $value );
588  }
589  }
590 
602  public static function maybeGetWebserverPrimaryGroup() {
603  if ( !function_exists( 'posix_getegid' ) || !function_exists( 'posix_getpwuid' ) ) {
604  # I don't know this, this isn't UNIX.
605  return null;
606  }
607 
608  # posix_getegid() *not* getmygid() because we want the group of the webserver,
609  # not whoever owns the current script.
610  $gid = posix_getegid();
611  $group = posix_getpwuid( $gid )['name'];
612 
613  return $group;
614  }
615 
632  public function parse( $text, $lineStart = false ) {
634 
635  try {
636  $out = $wgParser->parse( $text, $this->parserTitle, $this->parserOptions, $lineStart );
637  $html = $out->getText();
638  } catch ( DBAccessError $e ) {
639  $html = '<!--DB access attempted during parse--> ' . htmlspecialchars( $text );
640 
641  if ( !empty( $this->debug ) ) {
642  $html .= "<!--\n" . $e->getTraceAsString() . "\n-->";
643  }
644  }
645 
646  return $html;
647  }
648 
652  public function getParserOptions() {
653  return $this->parserOptions;
654  }
655 
656  public function disableLinkPopups() {
657  $this->parserOptions->setExternalLinkTarget( false );
658  }
659 
660  public function restoreLinkPopups() {
661  global $wgExternalLinkTarget;
662  $this->parserOptions->setExternalLinkTarget( $wgExternalLinkTarget );
663  }
664 
673  public function populateSiteStats( DatabaseInstaller $installer ) {
674  $status = $installer->getConnection();
675  if ( !$status->isOK() ) {
676  return $status;
677  }
678  $status->value->insert(
679  'site_stats',
680  [
681  'ss_row_id' => 1,
682  'ss_total_edits' => 0,
683  'ss_good_articles' => 0,
684  'ss_total_pages' => 0,
685  'ss_users' => 0,
686  'ss_images' => 0
687  ],
688  __METHOD__, 'IGNORE'
689  );
690 
691  return Status::newGood();
692  }
693 
698  protected function envCheckDB() {
699  global $wgLang;
700 
701  $allNames = [];
702 
703  // Messages: config-type-mysql, config-type-postgres, config-type-oracle,
704  // config-type-sqlite
705  foreach ( self::getDBTypes() as $name ) {
706  $allNames[] = wfMessage( "config-type-$name" )->text();
707  }
708 
709  $databases = $this->getCompiledDBs();
710 
711  $databases = array_flip( $databases );
712  foreach ( array_keys( $databases ) as $db ) {
713  $installer = $this->getDBInstaller( $db );
714  $status = $installer->checkPrerequisites();
715  if ( !$status->isGood() ) {
716  $this->showStatusMessage( $status );
717  }
718  if ( !$status->isOK() ) {
719  unset( $databases[$db] );
720  }
721  }
722  $databases = array_flip( $databases );
723  if ( !$databases ) {
724  $this->showError( 'config-no-db', $wgLang->commaList( $allNames ), count( $allNames ) );
725 
726  // @todo FIXME: This only works for the web installer!
727  return false;
728  }
729 
730  return true;
731  }
732 
737  protected function envCheckBrokenXML() {
738  $test = new PhpXmlBugTester();
739  if ( !$test->ok ) {
740  $this->showError( 'config-brokenlibxml' );
741 
742  return false;
743  }
744 
745  return true;
746  }
747 
756  protected function envCheckPCRE() {
757  MediaWiki\suppressWarnings();
758  $regexd = preg_replace( '/[\x{0430}-\x{04FF}]/iu', '', '-АБВГД-' );
759  // Need to check for \p support too, as PCRE can be compiled
760  // with utf8 support, but not unicode property support.
761  // check that \p{Zs} (space separators) matches
762  // U+3000 (Ideographic space)
763  $regexprop = preg_replace( '/\p{Zs}/u', '', "-\xE3\x80\x80-" );
764  MediaWiki\restoreWarnings();
765  if ( $regexd != '--' || $regexprop != '--' ) {
766  $this->showError( 'config-pcre-no-utf8' );
767 
768  return false;
769  }
770 
771  return true;
772  }
773 
778  protected function envCheckMemory() {
779  $limit = ini_get( 'memory_limit' );
780 
781  if ( !$limit || $limit == -1 ) {
782  return true;
783  }
784 
786 
787  if ( $n < $this->minMemorySize * 1024 * 1024 ) {
788  $newLimit = "{$this->minMemorySize}M";
789 
790  if ( ini_set( "memory_limit", $newLimit ) === false ) {
791  $this->showMessage( 'config-memory-bad', $limit );
792  } else {
793  $this->showMessage( 'config-memory-raised', $limit, $newLimit );
794  $this->setVar( '_RaiseMemory', true );
795  }
796  }
797 
798  return true;
799  }
800 
804  protected function envCheckCache() {
805  $caches = [];
806  foreach ( $this->objectCaches as $name => $function ) {
807  if ( function_exists( $function ) ) {
808  if ( $name == 'xcache' && !wfIniGetBool( 'xcache.var_size' ) ) {
809  continue;
810  }
811  $caches[$name] = true;
812  }
813  }
814 
815  if ( !$caches ) {
816  $key = 'config-no-cache-apcu';
817  $this->showMessage( $key );
818  }
819 
820  $this->setVar( '_Caches', $caches );
821  }
822 
827  protected function envCheckModSecurity() {
828  if ( self::apacheModulePresent( 'mod_security' )
829  || self::apacheModulePresent( 'mod_security2' ) ) {
830  $this->showMessage( 'config-mod-security' );
831  }
832 
833  return true;
834  }
835 
840  protected function envCheckDiff3() {
841  $names = [ "gdiff3", "diff3", "diff3.exe" ];
842  $versionInfo = [ '$1 --version 2>&1', 'GNU diffutils' ];
843 
844  $diff3 = self::locateExecutableInDefaultPaths( $names, $versionInfo );
845 
846  if ( $diff3 ) {
847  $this->setVar( 'wgDiff3', $diff3 );
848  } else {
849  $this->setVar( 'wgDiff3', false );
850  $this->showMessage( 'config-diff3-bad' );
851  }
852 
853  return true;
854  }
855 
860  protected function envCheckGraphics() {
861  $names = [ wfIsWindows() ? 'convert.exe' : 'convert' ];
862  $versionInfo = [ '$1 -version', 'ImageMagick' ];
863  $convert = self::locateExecutableInDefaultPaths( $names, $versionInfo );
864 
865  $this->setVar( 'wgImageMagickConvertCommand', '' );
866  if ( $convert ) {
867  $this->setVar( 'wgImageMagickConvertCommand', $convert );
868  $this->showMessage( 'config-imagemagick', $convert );
869 
870  return true;
871  } elseif ( function_exists( 'imagejpeg' ) ) {
872  $this->showMessage( 'config-gd' );
873  } else {
874  $this->showMessage( 'config-no-scaling' );
875  }
876 
877  return true;
878  }
879 
886  protected function envCheckGit() {
887  $names = [ wfIsWindows() ? 'git.exe' : 'git' ];
888  $versionInfo = [ '$1 --version', 'git version' ];
889 
890  $git = self::locateExecutableInDefaultPaths( $names, $versionInfo );
891 
892  if ( $git ) {
893  $this->setVar( 'wgGitBin', $git );
894  $this->showMessage( 'config-git', $git );
895  } else {
896  $this->setVar( 'wgGitBin', false );
897  $this->showMessage( 'config-git-bad' );
898  }
899 
900  return true;
901  }
902 
908  protected function envCheckServer() {
909  $server = $this->envGetDefaultServer();
910  if ( $server !== null ) {
911  $this->showMessage( 'config-using-server', $server );
912  }
913  return true;
914  }
915 
921  protected function envCheckPath() {
922  $this->showMessage(
923  'config-using-uri',
924  $this->getVar( 'wgServer' ),
925  $this->getVar( 'wgScriptPath' )
926  );
927  return true;
928  }
929 
934  protected function envCheckShellLocale() {
935  $os = php_uname( 's' );
936  $supported = [ 'Linux', 'SunOS', 'HP-UX', 'Darwin' ]; # Tested these
937 
938  if ( !in_array( $os, $supported ) ) {
939  return true;
940  }
941 
942  # Get a list of available locales.
943  $ret = false;
944  $lines = wfShellExec( '/usr/bin/locale -a', $ret );
945 
946  if ( $ret ) {
947  return true;
948  }
949 
950  $lines = array_map( 'trim', explode( "\n", $lines ) );
951  $candidatesByLocale = [];
952  $candidatesByLang = [];
953 
954  foreach ( $lines as $line ) {
955  if ( $line === '' ) {
956  continue;
957  }
958 
959  if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) {
960  continue;
961  }
962 
963  list( , $lang, , , ) = $m;
964 
965  $candidatesByLocale[$m[0]] = $m;
966  $candidatesByLang[$lang][] = $m;
967  }
968 
969  # Try the current value of LANG.
970  if ( isset( $candidatesByLocale[getenv( 'LANG' )] ) ) {
971  $this->setVar( 'wgShellLocale', getenv( 'LANG' ) );
972 
973  return true;
974  }
975 
976  # Try the most common ones.
977  $commonLocales = [ 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' ];
978  foreach ( $commonLocales as $commonLocale ) {
979  if ( isset( $candidatesByLocale[$commonLocale] ) ) {
980  $this->setVar( 'wgShellLocale', $commonLocale );
981 
982  return true;
983  }
984  }
985 
986  # Is there an available locale in the Wiki's language?
987  $wikiLang = $this->getVar( 'wgLanguageCode' );
988 
989  if ( isset( $candidatesByLang[$wikiLang] ) ) {
990  $m = reset( $candidatesByLang[$wikiLang] );
991  $this->setVar( 'wgShellLocale', $m[0] );
992 
993  return true;
994  }
995 
996  # Are there any at all?
997  if ( count( $candidatesByLocale ) ) {
998  $m = reset( $candidatesByLocale );
999  $this->setVar( 'wgShellLocale', $m[0] );
1000 
1001  return true;
1002  }
1003 
1004  # Give up.
1005  return true;
1006  }
1007 
1012  protected function envCheckUploadsDirectory() {
1013  global $IP;
1014 
1015  $dir = $IP . '/images/';
1016  $url = $this->getVar( 'wgServer' ) . $this->getVar( 'wgScriptPath' ) . '/images/';
1017  $safe = !$this->dirIsExecutable( $dir, $url );
1018 
1019  if ( !$safe ) {
1020  $this->showMessage( 'config-uploads-not-safe', $dir );
1021  }
1022 
1023  return true;
1024  }
1025 
1031  protected function envCheckSuhosinMaxValueLength() {
1032  $maxValueLength = ini_get( 'suhosin.get.max_value_length' );
1033  if ( $maxValueLength > 0 && $maxValueLength < 1024 ) {
1034  // Only warn if the value is below the sane 1024
1035  $this->showMessage( 'config-suhosin-max-value-length', $maxValueLength );
1036  }
1037 
1038  return true;
1039  }
1040 
1046  protected function unicodeChar( $c ) {
1047  $c = hexdec( $c );
1048  if ( $c <= 0x7F ) {
1049  return chr( $c );
1050  } elseif ( $c <= 0x7FF ) {
1051  return chr( 0xC0 | $c >> 6 ) . chr( 0x80 | $c & 0x3F );
1052  } elseif ( $c <= 0xFFFF ) {
1053  return chr( 0xE0 | $c >> 12 ) . chr( 0x80 | $c >> 6 & 0x3F ) .
1054  chr( 0x80 | $c & 0x3F );
1055  } elseif ( $c <= 0x10FFFF ) {
1056  return chr( 0xF0 | $c >> 18 ) . chr( 0x80 | $c >> 12 & 0x3F ) .
1057  chr( 0x80 | $c >> 6 & 0x3F ) .
1058  chr( 0x80 | $c & 0x3F );
1059  } else {
1060  return false;
1061  }
1062  }
1063 
1067  protected function envCheckLibicu() {
1075  $not_normal_c = $this->unicodeChar( "FA6C" );
1076  $normal_c = $this->unicodeChar( "242EE" );
1077 
1078  $useNormalizer = 'php';
1079  $needsUpdate = false;
1080 
1081  if ( function_exists( 'normalizer_normalize' ) ) {
1082  $useNormalizer = 'intl';
1083  $intl = normalizer_normalize( $not_normal_c, Normalizer::FORM_C );
1084  if ( $intl !== $normal_c ) {
1085  $needsUpdate = true;
1086  }
1087  }
1088 
1089  // Uses messages 'config-unicode-using-php' and 'config-unicode-using-intl'
1090  if ( $useNormalizer === 'php' ) {
1091  $this->showMessage( 'config-unicode-pure-php-warning' );
1092  } else {
1093  $this->showMessage( 'config-unicode-using-' . $useNormalizer );
1094  if ( $needsUpdate ) {
1095  $this->showMessage( 'config-unicode-update-warning' );
1096  }
1097  }
1098  }
1099 
1103  protected function envPrepServer() {
1104  $server = $this->envGetDefaultServer();
1105  if ( $server !== null ) {
1106  $this->setVar( 'wgServer', $server );
1107  }
1108  }
1109 
1114  abstract protected function envGetDefaultServer();
1115 
1119  protected function envPrepPath() {
1120  global $IP;
1121  $IP = dirname( dirname( __DIR__ ) );
1122  $this->setVar( 'IP', $IP );
1123  }
1124 
1132  protected static function getPossibleBinPaths() {
1133  return array_merge(
1134  [ '/usr/bin', '/usr/local/bin', '/opt/csw/bin',
1135  '/usr/gnu/bin', '/usr/sfw/bin', '/sw/bin', '/opt/local/bin' ],
1136  explode( PATH_SEPARATOR, getenv( 'PATH' ) )
1137  );
1138  }
1139 
1157  public static function locateExecutable( $path, $names, $versionInfo = false ) {
1158  if ( !is_array( $names ) ) {
1159  $names = [ $names ];
1160  }
1161 
1162  foreach ( $names as $name ) {
1163  $command = $path . DIRECTORY_SEPARATOR . $name;
1164 
1165  MediaWiki\suppressWarnings();
1166  $file_exists = file_exists( $command );
1167  MediaWiki\restoreWarnings();
1168 
1169  if ( $file_exists ) {
1170  if ( !$versionInfo ) {
1171  return $command;
1172  }
1173 
1174  $file = str_replace( '$1', wfEscapeShellArg( $command ), $versionInfo[0] );
1175  if ( strstr( wfShellExec( $file ), $versionInfo[1] ) !== false ) {
1176  return $command;
1177  }
1178  }
1179  }
1180 
1181  return false;
1182  }
1183 
1196  public static function locateExecutableInDefaultPaths( $names, $versionInfo = false ) {
1197  foreach ( self::getPossibleBinPaths() as $path ) {
1198  $exe = self::locateExecutable( $path, $names, $versionInfo );
1199  if ( $exe !== false ) {
1200  return $exe;
1201  }
1202  }
1203 
1204  return false;
1205  }
1206 
1215  public function dirIsExecutable( $dir, $url ) {
1216  $scriptTypes = [
1217  'php' => [
1218  "<?php echo 'ex' . 'ec';",
1219  "#!/var/env php5\n<?php echo 'ex' . 'ec';",
1220  ],
1221  ];
1222 
1223  // it would be good to check other popular languages here, but it'll be slow.
1224 
1225  MediaWiki\suppressWarnings();
1226 
1227  foreach ( $scriptTypes as $ext => $contents ) {
1228  foreach ( $contents as $source ) {
1229  $file = 'exectest.' . $ext;
1230 
1231  if ( !file_put_contents( $dir . $file, $source ) ) {
1232  break;
1233  }
1234 
1235  try {
1236  $text = Http::get( $url . $file, [ 'timeout' => 3 ], __METHOD__ );
1237  } catch ( Exception $e ) {
1238  // Http::get throws with allow_url_fopen = false and no curl extension.
1239  $text = null;
1240  }
1241  unlink( $dir . $file );
1242 
1243  if ( $text == 'exec' ) {
1244  MediaWiki\restoreWarnings();
1245 
1246  return $ext;
1247  }
1248  }
1249  }
1250 
1251  MediaWiki\restoreWarnings();
1252 
1253  return false;
1254  }
1255 
1262  public static function apacheModulePresent( $moduleName ) {
1263  if ( function_exists( 'apache_get_modules' ) && in_array( $moduleName, apache_get_modules() ) ) {
1264  return true;
1265  }
1266  // try it the hard way
1267  ob_start();
1268  phpinfo( INFO_MODULES );
1269  $info = ob_get_clean();
1270 
1271  return strpos( $info, $moduleName ) !== false;
1272  }
1273 
1279  public function setParserLanguage( $lang ) {
1280  $this->parserOptions->setTargetLanguage( $lang );
1281  $this->parserOptions->setUserLang( $lang );
1282  }
1283 
1289  protected function getDocUrl( $page ) {
1290  return "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
1291  }
1292 
1302  public function findExtensions( $directory = 'extensions' ) {
1303  if ( $this->getVar( 'IP' ) === null ) {
1304  return [];
1305  }
1306 
1307  $extDir = $this->getVar( 'IP' ) . '/' . $directory;
1308  if ( !is_readable( $extDir ) || !is_dir( $extDir ) ) {
1309  return [];
1310  }
1311 
1312  // extensions -> extension.json, skins -> skin.json
1313  $jsonFile = substr( $directory, 0, strlen( $directory ) -1 ) . '.json';
1314 
1315  $dh = opendir( $extDir );
1316  $exts = [];
1317  while ( ( $file = readdir( $dh ) ) !== false ) {
1318  if ( !is_dir( "$extDir/$file" ) ) {
1319  continue;
1320  }
1321  if ( file_exists( "$extDir/$file/$jsonFile" ) || file_exists( "$extDir/$file/$file.php" ) ) {
1322  $exts[] = $file;
1323  }
1324  }
1325  closedir( $dh );
1326  natcasesort( $exts );
1327 
1328  return $exts;
1329  }
1330 
1339  public function getDefaultSkin( array $skinNames ) {
1340  $defaultSkin = $GLOBALS['wgDefaultSkin'];
1341  if ( !$skinNames || in_array( $defaultSkin, $skinNames ) ) {
1342  return $defaultSkin;
1343  } else {
1344  return $skinNames[0];
1345  }
1346  }
1347 
1353  protected function includeExtensions() {
1354  global $IP;
1355  $exts = $this->getVar( '_Extensions' );
1356  $IP = $this->getVar( 'IP' );
1357 
1367  $wgAutoloadClasses = [];
1368  $queue = [];
1369 
1370  require "$IP/includes/DefaultSettings.php";
1371 
1372  foreach ( $exts as $e ) {
1373  if ( file_exists( "$IP/extensions/$e/extension.json" ) ) {
1374  $queue["$IP/extensions/$e/extension.json"] = 1;
1375  } else {
1376  require_once "$IP/extensions/$e/$e.php";
1377  }
1378  }
1379 
1380  $registry = new ExtensionRegistry();
1381  $data = $registry->readFromQueue( $queue );
1382  $wgAutoloadClasses += $data['autoload'];
1383 
1384  $hooksWeWant = isset( $wgHooks['LoadExtensionSchemaUpdates'] ) ?
1385  $wgHooks['LoadExtensionSchemaUpdates'] : [];
1386 
1387  if ( isset( $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {
1388  $hooksWeWant = array_merge_recursive(
1389  $hooksWeWant,
1390  $data['globals']['wgHooks']['LoadExtensionSchemaUpdates']
1391  );
1392  }
1393  // Unset everyone else's hooks. Lord knows what someone might be doing
1394  // in ParserFirstCallInit (see bug 27171)
1395  $GLOBALS['wgHooks'] = [ 'LoadExtensionSchemaUpdates' => $hooksWeWant ];
1396 
1397  return Status::newGood();
1398  }
1399 
1412  protected function getInstallSteps( DatabaseInstaller $installer ) {
1413  $coreInstallSteps = [
1414  [ 'name' => 'database', 'callback' => [ $installer, 'setupDatabase' ] ],
1415  [ 'name' => 'tables', 'callback' => [ $installer, 'createTables' ] ],
1416  [ 'name' => 'interwiki', 'callback' => [ $installer, 'populateInterwikiTable' ] ],
1417  [ 'name' => 'stats', 'callback' => [ $this, 'populateSiteStats' ] ],
1418  [ 'name' => 'keys', 'callback' => [ $this, 'generateKeys' ] ],
1419  [ 'name' => 'updates', 'callback' => [ $installer, 'insertUpdateKeys' ] ],
1420  [ 'name' => 'sysop', 'callback' => [ $this, 'createSysop' ] ],
1421  [ 'name' => 'mainpage', 'callback' => [ $this, 'createMainpage' ] ],
1422  ];
1423 
1424  // Build the array of install steps starting from the core install list,
1425  // then adding any callbacks that wanted to attach after a given step
1426  foreach ( $coreInstallSteps as $step ) {
1427  $this->installSteps[] = $step;
1428  if ( isset( $this->extraInstallSteps[$step['name']] ) ) {
1429  $this->installSteps = array_merge(
1430  $this->installSteps,
1431  $this->extraInstallSteps[$step['name']]
1432  );
1433  }
1434  }
1435 
1436  // Prepend any steps that want to be at the beginning
1437  if ( isset( $this->extraInstallSteps['BEGINNING'] ) ) {
1438  $this->installSteps = array_merge(
1439  $this->extraInstallSteps['BEGINNING'],
1440  $this->installSteps
1441  );
1442  }
1443 
1444  // Extensions should always go first, chance to tie into hooks and such
1445  if ( count( $this->getVar( '_Extensions' ) ) ) {
1446  array_unshift( $this->installSteps,
1447  [ 'name' => 'extensions', 'callback' => [ $this, 'includeExtensions' ] ]
1448  );
1449  $this->installSteps[] = [
1450  'name' => 'extension-tables',
1451  'callback' => [ $installer, 'createExtensionTables' ]
1452  ];
1453  }
1454 
1455  return $this->installSteps;
1456  }
1457 
1466  public function performInstallation( $startCB, $endCB ) {
1467  $installResults = [];
1468  $installer = $this->getDBInstaller();
1469  $installer->preInstall();
1470  $steps = $this->getInstallSteps( $installer );
1471  foreach ( $steps as $stepObj ) {
1472  $name = $stepObj['name'];
1473  call_user_func_array( $startCB, [ $name ] );
1474 
1475  // Perform the callback step
1476  $status = call_user_func( $stepObj['callback'], $installer );
1477 
1478  // Output and save the results
1479  call_user_func( $endCB, $name, $status );
1480  $installResults[$name] = $status;
1481 
1482  // If we've hit some sort of fatal, we need to bail.
1483  // Callback already had a chance to do output above.
1484  if ( !$status->isOk() ) {
1485  break;
1486  }
1487  }
1488  if ( $status->isOk() ) {
1489  $this->setVar( '_InstallDone', true );
1490  }
1491 
1492  return $installResults;
1493  }
1494 
1500  public function generateKeys() {
1501  $keys = [ 'wgSecretKey' => 64 ];
1502  if ( strval( $this->getVar( 'wgUpgradeKey' ) ) === '' ) {
1503  $keys['wgUpgradeKey'] = 16;
1504  }
1505 
1506  return $this->doGenerateKeys( $keys );
1507  }
1508 
1516  protected function doGenerateKeys( $keys ) {
1518 
1519  $strong = true;
1520  foreach ( $keys as $name => $length ) {
1521  $secretKey = MWCryptRand::generateHex( $length, true );
1522  if ( !MWCryptRand::wasStrong() ) {
1523  $strong = false;
1524  }
1525 
1526  $this->setVar( $name, $secretKey );
1527  }
1528 
1529  if ( !$strong ) {
1530  $names = array_keys( $keys );
1531  $names = preg_replace( '/^(.*)$/', '\$$1', $names );
1532  global $wgLang;
1533  $status->warning( 'config-insecure-keys', $wgLang->listToText( $names ), count( $names ) );
1534  }
1535 
1536  return $status;
1537  }
1538 
1544  protected function createSysop() {
1545  $name = $this->getVar( '_AdminName' );
1547 
1548  if ( !$user ) {
1549  // We should've validated this earlier anyway!
1550  return Status::newFatal( 'config-admin-error-user', $name );
1551  }
1552 
1553  if ( $user->idForName() == 0 ) {
1554  $user->addToDatabase();
1555 
1556  try {
1557  $user->setPassword( $this->getVar( '_AdminPassword' ) );
1558  } catch ( PasswordError $pwe ) {
1559  return Status::newFatal( 'config-admin-error-password', $name, $pwe->getMessage() );
1560  }
1561 
1562  $user->addGroup( 'sysop' );
1563  $user->addGroup( 'bureaucrat' );
1564  if ( $this->getVar( '_AdminEmail' ) ) {
1565  $user->setEmail( $this->getVar( '_AdminEmail' ) );
1566  }
1567  $user->saveSettings();
1568 
1569  // Update user count
1570  $ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
1571  $ssUpdate->doUpdate();
1572  }
1574 
1575  if ( $this->getVar( '_Subscribe' ) && $this->getVar( '_AdminEmail' ) ) {
1577  }
1578 
1579  return $status;
1580  }
1581 
1586  $params = [
1587  'email' => $this->getVar( '_AdminEmail' ),
1588  'language' => 'en',
1589  'digest' => 0
1590  ];
1591 
1592  // Mailman doesn't support as many languages as we do, so check to make
1593  // sure their selected language is available
1594  $myLang = $this->getVar( '_UserLang' );
1595  if ( in_array( $myLang, $this->mediaWikiAnnounceLanguages ) ) {
1596  $myLang = $myLang == 'pt-br' ? 'pt_BR' : $myLang; // rewrite to Mailman's pt_BR
1597  $params['language'] = $myLang;
1598  }
1599 
1601  $res = MWHttpRequest::factory( $this->mediaWikiAnnounceUrl,
1602  [ 'method' => 'POST', 'postData' => $params ], __METHOD__ )->execute();
1603  if ( !$res->isOK() ) {
1604  $s->warning( 'config-install-subscribe-fail', $res->getMessage() );
1605  }
1606  } else {
1607  $s->warning( 'config-install-subscribe-notpossible' );
1608  }
1609  }
1610 
1617  protected function createMainpage( DatabaseInstaller $installer ) {
1619  try {
1621  $content = new WikitextContent(
1622  wfMessage( 'mainpagetext' )->inContentLanguage()->text() . "\n\n" .
1623  wfMessage( 'mainpagedocfooter' )->inContentLanguage()->text()
1624  );
1625 
1626  $status = $page->doEditContent( $content,
1627  '',
1628  EDIT_NEW,
1629  false,
1630  User::newFromName( 'MediaWiki default' )
1631  );
1632  } catch ( Exception $e ) {
1633  // using raw, because $wgShowExceptionDetails can not be set yet
1634  $status->fatal( 'config-install-mainpage-failed', $e->getMessage() );
1635  }
1636 
1637  return $status;
1638  }
1639 
1643  public static function overrideConfig() {
1644  // Use PHP's built-in session handling, since MediaWiki's
1645  // SessionHandler can't work before we have an object cache set up.
1646  define( 'MW_NO_SESSION_HANDLER', 1 );
1647 
1648  // Don't access the database
1649  $GLOBALS['wgUseDatabaseMessages'] = false;
1650  // Don't cache langconv tables
1651  $GLOBALS['wgLanguageConverterCacheType'] = CACHE_NONE;
1652  // Debug-friendly
1653  $GLOBALS['wgShowExceptionDetails'] = true;
1654  // Don't break forms
1655  $GLOBALS['wgExternalLinkTarget'] = '_blank';
1656 
1657  // Extended debugging
1658  $GLOBALS['wgShowSQLErrors'] = true;
1659  $GLOBALS['wgShowDBErrorBacktrace'] = true;
1660 
1661  // Allow multiple ob_flush() calls
1662  $GLOBALS['wgDisableOutputCompression'] = true;
1663 
1664  // Use a sensible cookie prefix (not my_wiki)
1665  $GLOBALS['wgCookiePrefix'] = 'mw_installer';
1666 
1667  // Some of the environment checks make shell requests, remove limits
1668  $GLOBALS['wgMaxShellMemory'] = 0;
1669 
1670  // Override the default CookieSessionProvider with a dummy
1671  // implementation that won't stomp on PHP's cookies.
1672  $GLOBALS['wgSessionProviders'] = [
1673  [
1674  'class' => 'InstallerSessionProvider',
1675  'args' => [ [
1676  'priority' => 1,
1677  ] ]
1678  ]
1679  ];
1680 
1681  // Don't try to use any object cache for SessionManager either.
1682  $GLOBALS['wgSessionCacheType'] = CACHE_NONE;
1683  }
1684 
1692  public function addInstallStep( $callback, $findStep = 'BEGINNING' ) {
1693  $this->extraInstallSteps[$findStep][] = $callback;
1694  }
1695 
1700  protected function disableTimeLimit() {
1701  MediaWiki\suppressWarnings();
1702  set_time_limit( 0 );
1703  MediaWiki\restoreWarnings();
1704  }
1705 }
static newFromName($name, $validate= 'valid')
Static factory method for creation from username.
Definition: User.php:568
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:99
envCheckServer()
Environment check to inform user which server we've assumed.
Definition: Installer.php:908
array $internalDefaults
Variables that are stored alongside globals, and are used for any configuration of the installation p...
Definition: Installer.php:191
envCheckBrokenXML()
Some versions of libxml+PHP break < and > encoding horribly.
Definition: Installer.php:737
static getLocalisationCache()
Get the LocalisationCache instance.
Definition: Language.php:402
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:1798
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
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:762
the array() calling protocol came about after MediaWiki 1.4rc1.
magic word the default is to use $key to get the and $key value or $key value text $key value html to format the value $key
Definition: hooks.txt:2321
Title $parserTitle
Cached Title, used by parse().
Definition: Installer.php:83
performInstallation($startCB, $endCB)
Actually perform the installation.
Definition: Installer.php:1466
array $dbInstallers
Cached DB installer instances, access using getDBInstaller().
Definition: Installer.php:69
if(count($args)==0) $dir
wfIsHHVM()
Check if we are running under HHVM.
restoreLinkPopups()
Definition: Installer.php:660
static newMainPage()
Create a new Title for the Main Page.
Definition: Title.php:569
dirIsExecutable($dir, $url)
Checks if scripts located in the given directory can be executed via the given URL.
Definition: Installer.php:1215
$IP
Definition: WebStart.php:58
setVar($name, $value)
Set a MW configuration variable, or internal installer configuration variable.
Definition: Installer.php:475
wfShorthandToInteger($string= '', $default=-1)
Converts shorthand byte notation to integer form.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
Definition: hooks.txt:1932
$command
Definition: cdb.php:65
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:1798
envPrepPath()
Environment prep for setting $IP and $wgScriptPath.
Definition: Installer.php:1119
Set options of the Parser.
$wgParser
Definition: Setup.php:809
if(!isset($args[0])) $lang
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
envCheckShellLocale()
Environment check for preferred locale in shell.
Definition: Installer.php:934
includeExtensions()
Installs the auto-detected extensions.
Definition: Installer.php:1353
envCheckGraphics()
Environment check for ImageMagick and GD.
Definition: Installer.php:860
$source
$value
static newFromId($id)
Static factory method for creation from a given user ID.
Definition: User.php:591
doEnvironmentPreps()
Definition: Installer.php:463
envCheckGit()
Search for git.
Definition: Installer.php:886
static wasStrong()
Return a boolean indicating whether or not the source used for cryptographic random bytes generation ...
array $settings
Definition: Installer.php:55
$wgHooks['ArticleShow'][]
Definition: hooks.txt:110
static locateExecutableInDefaultPaths($names, $versionInfo=false)
Same as locateExecutable(), but checks in getPossibleBinPaths() by default.
Definition: Installer.php:1196
envCheckDiff3()
Search for GNU diff3.
Definition: Installer.php:840
ParserOptions $parserOptions
Cached ParserOptions, used by parse().
Definition: Installer.php:90
wfShellExec($cmd, &$retval=null, $environ=[], $limits=[], $options=[])
Execute a shell command, with time and memory limits mirrored from the PHP configuration if supported...
envCheckModSecurity()
Scare user to death if they have mod_security or mod_security2.
Definition: Installer.php:827
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:277
doGenerateKeys($keys)
Generate a secret value for variables using our CryptRand generator.
Definition: Installer.php:1516
when a variable name is used in a it is silently declared as a new local masking the global
Definition: design.txt:93
addInstallStep($callback, $findStep= 'BEGINNING')
Add an installation step following the given step.
Definition: Installer.php:1692
wfIsWindows()
Check if the operating system is Windows.
static newFatal($message)
Factory function for fatal errors.
Definition: Status.php:89
static canMakeRequests()
Simple function to test if we can make any sort of requests at all, using cURL or fopen() ...
warning($message)
Add a new warning.
Definition: Status.php:150
static disableBackend()
Disables all access to the load balancer, will cause all database access to throw a DBAccessError...
Definition: LBFactory.php:67
const CACHE_MEMCACHED
Definition: Defines.php:104
getConnection()
Connect to the database using the administrative user/password currently defined in the session...
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
getDocUrl($page)
Overridden by WebInstaller to provide lastPage parameters.
Definition: Installer.php:1289
array $objectCaches
Known object cache types and the functions used to test for their existence.
Definition: Installer.php:242
$wgExtensionDirectory
Filesystem extensions directory.
findExtensions($directory= 'extensions')
Finds extensions that follow the format /$directory/Name/Name.php, and returns an array containing th...
Definition: Installer.php:1302
showStatusMessage(Status $status)
Show a message to the installing user by using a Status object.
envCheckSuhosinMaxValueLength()
Checks if suhosin.get.max_value_length is set, and if so generate a warning because it decreases Reso...
Definition: Installer.php:1031
$mediaWikiAnnounceLanguages
Supported language codes for Mailman.
Definition: Installer.php:326
static getMain()
Static methods.
generateKeys()
Generate $wgSecretKey.
Definition: Installer.php:1500
$GLOBALS['IP']
static maybeGetWebserverPrimaryGroup()
On POSIX systems return the primary group of the webserver we're running under.
Definition: Installer.php:602
array $envPreps
A list of environment preparation methods called by doEnvironmentPreps().
Definition: Installer.php:143
array $envChecks
A list of environment check methods called by doEnvironmentChecks().
Definition: Installer.php:120
wfIniGetBool($setting)
Safety wrapper around ini_get() for boolean settings.
$res
Definition: database.txt:21
showMessage($msg)
UI interface for displaying a short message The parameters are like parameters to wfMessage()...
static locateExecutable($path, $names, $versionInfo=false)
Search a path for any of the given executable names.
Definition: Installer.php:1157
Class for handling updates to the site_stats table.
array array $installSteps
The actual list of installation steps.
Definition: Installer.php:228
parse($text, $lineStart=false)
Convert wikitext $text to HTML.
Definition: Installer.php:632
static getExistingLocalSettings()
Determine if LocalSettings.php exists.
Definition: Installer.php:533
Exception class for attempted DB access.
Definition: LBFactory.php:470
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 after processing 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 unsetoffset-wrap String Wrap the message in html(usually something like"&lt
int $minMemorySize
Minimum memory size in MB.
Definition: Installer.php:76
$params
getInstallSteps(DatabaseInstaller $installer)
Get an array of install steps.
Definition: Installer.php:1412
array $compiledDBs
List of detected DBs, access using getCompiledDBs().
Definition: Installer.php:62
getParserOptions()
Definition: Installer.php:652
showError($msg)
Same as showMessage(), but for displaying errors.
A BagOStuff object with no objects in it.
global $wgAutoloadClasses
disableTimeLimit()
Disable the time limit for execution.
Definition: Installer.php:1700
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:12
static apacheModulePresent($moduleName)
Checks for presence of an Apache module.
Definition: Installer.php:1262
Content object for wiki text pages.
Test for PHP+libxml2 bug which breaks XML input subtly with certain versions.
Definition: PhpBugTests.php:30
array array $rightsProfiles
User rights profiles.
Definition: Installer.php:254
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:25
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
Definition: distributors.txt:9
createMainpage(DatabaseInstaller $installer)
Insert Main Page with default content.
Definition: Installer.php:1617
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:242
disableLinkPopups()
Definition: Installer.php:656
setPassword($name, $value)
Set a variable which stores a password, except if the new value is a fake password in which case leav...
Definition: Installer.php:585
unicodeChar($c)
Convert a hex string representing a Unicode code point to that code point.
Definition: Installer.php:1046
envCheckCache()
Environment check for compiled object cache types.
Definition: Installer.php:804
envCheckUploadsDirectory()
Environment check for the permissions of the uploads directory.
Definition: Installer.php:1012
ExtensionRegistry class.
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:35
const MINIMUM_PCRE_VERSION
The oldest version of PCRE we can support.
Definition: Installer.php:50
envCheckDB()
Environment check for DB types.
Definition: Installer.php:698
$lines
Definition: router.php:66
populateSiteStats(DatabaseInstaller $installer)
Install step which adds a row to the site_stats table with appropriate initial values.
Definition: Installer.php:673
Show an error when any operation involving passwords fails to run.
array $extraInstallSteps
Extra steps for installation, for things like DatabaseInstallers to modify.
Definition: Installer.php:235
getCompiledDBs()
Get a list of DBs supported by current PHP setup.
Definition: Installer.php:502
const EDIT_NEW
Definition: Defines.php:179
array array array $licenses
License types.
Definition: Installer.php:279
envGetDefaultServer()
Helper function to be called from envPrepServer()
getDBInstaller($type=false)
Get an instance of DatabaseInstaller for the specified DB type.
Definition: Installer.php:513
envCheckPCRE()
Environment check for the PCRE module.
Definition: Installer.php:756
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:1004
envCheckPath()
Environment check to inform user which paths we've assumed.
Definition: Installer.php:921
static generateHex($chars, $forceStrong=false)
Generate a run of (ideally) cryptographically random data and return it in hexadecimal string format...
$line
Definition: cdb.php:59
const CACHE_ANYTHING
Definition: Defines.php:101
__construct()
Constructor, always call this from child classes.
Definition: Installer.php:356
$wgStyleDirectory
Filesystem stylesheets directory.
static array $dbTypes
Known database types.
Definition: Installer.php:101
Base class for DBMS-specific installation helper classes.
static overrideConfig()
Override the necessary bits of the config to run an installation.
Definition: Installer.php:1643
Base installer class.
Definition: Installer.php:42
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:1004
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:1004
wfEscapeShellArg()
Windows-compatible version of escapeshellarg() Windows doesn't recognise single-quotes in the shell...
static factory($url, $options=null, $caller=__METHOD__)
Generate a new request object.
static clear()
Clear all the cached instances.
static getDBTypes()
Get a list of known DB types.
Definition: Installer.php:417
setParserLanguage($lang)
ParserOptions are constructed before we determined the language, so fix it.
Definition: Installer.php:1279
getFakePassword($realPassword)
Get a fake password for sending back to the user in HTML.
Definition: Installer.php:574
static get($url, $options=[], $caller=__METHOD__)
Simple wrapper for Http::request( 'GET' )
const CACHE_NONE
Definition: Defines.php:102
getVar($name, $default=null)
Get an MW configuration variable, or internal installer configuration variable.
Definition: Installer.php:489
envCheckLibicu()
Check the libicu version.
Definition: Installer.php:1067
envCheckMemory()
Environment check for available memory.
Definition: Installer.php:778
doEnvironmentChecks()
Do initial checks of the PHP environment.
Definition: Installer.php:434
createSysop()
Create the first user account, grant it sysop and bureaucrat rights.
Definition: Installer.php:1544
static getPossibleBinPaths()
Get an array of likely places we can find executables.
Definition: Installer.php:1132
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:2338
envPrepServer()
Environment prep for the server hostname.
Definition: Installer.php:1103
array array array $mediaWikiAnnounceUrl
URL to mediawiki-announce subscription.
Definition: Installer.php:320
static newGood($value=null)
Factory function for good results.
Definition: Status.php:101
array $defaultVarNames
MediaWiki configuration globals that will eventually be passed through to LocalSettings.php.
Definition: Installer.php:155
const CACHE_DB
Definition: Defines.php:103
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:2338
subscribeToMediaWikiAnnounce(Status $s)
Definition: Installer.php:1585
$wgUser
Definition: Setup.php:794
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:310
getDefaultSkin(array $skinNames)
Returns a default value to be used for $wgDefaultSkin: normally the one set in DefaultSettings, but will fall back to another if the default skin is missing and some other one is present instead.
Definition: Installer.php:1339