3 * Core installer web interface.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
25 * Class for the core installer web interface.
30 class WebInstaller
extends Installer
{
33 * @var WebInstallerOutput
45 * Cached session array.
52 * Captured PHP error text. Temporary.
59 * The main sequence of page names. These will be displayed in turn.
61 * To add a new installer page:
62 * * Add it to this WebInstaller::$pageSequence property
63 * * Add a "config-page-<name>" message
64 * * Add a "WebInstaller<name>" class
68 public $pageSequence = [
82 * Out of sequence pages, selectable by the user at any time.
86 protected $otherPages = [
91 'UpgradeDoc', // Can't use Upgrade due to Upgrade step
95 * Array of pages which have declared that they have been submitted, have validated
96 * their input, and need no further processing.
100 protected $happyPages;
103 * List of "skipped" pages. These are pages that will automatically continue
104 * to the next page on any GET request. To avoid breaking the "back" button,
105 * they need to be skipped during a back operation.
109 protected $skippedPages;
112 * Flag indicating that session data may have been lost.
116 public $showSessionWarning = false;
119 * Numeric index of the page we're on
123 protected $tabIndex = 1;
126 * Name of the page we're on
130 protected $currentPageName;
133 * @param WebRequest $request
135 public function __construct( WebRequest
$request ) {
136 parent
::__construct();
137 $this->output
= new WebInstallerOutput( $this );
138 $this->request
= $request;
142 $wgParser->setHook( 'downloadlink', [ $this, 'downloadLinkHook' ] );
143 $wgParser->setHook( 'doclink', [ $this, 'docLink' ] );
149 * @param array[] $session Initial session array
151 * @return array[] New session array
153 public function execute( array $session ) {
154 $this->session
= $session;
156 if ( isset( $session['settings'] ) ) {
157 $this->settings
= $session['settings'] +
$this->settings
;
160 $this->setupLanguage();
162 if ( ( $this->getVar( '_InstallDone' ) ||
$this->getVar( '_UpgradeDone' ) )
163 && $this->request
->getVal( 'localsettings' )
165 $this->request
->response()->header( 'Content-type: application/x-httpd-php' );
166 $this->request
->response()->header(
167 'Content-Disposition: attachment; filename="LocalSettings.php"'
170 $ls = InstallerOverrides
::getLocalSettingsGenerator( $this );
171 $rightsProfile = $this->rightsProfiles
[$this->getVar( '_RightsProfile' )];
172 foreach ( $rightsProfile as $group => $rightsArr ) {
173 $ls->setGroupRights( $group, $rightsArr );
177 return $this->session
;
180 $isCSS = $this->request
->getVal( 'css' );
183 return $this->session
;
186 if ( isset( $session['happyPages'] ) ) {
187 $this->happyPages
= $session['happyPages'];
189 $this->happyPages
= [];
192 if ( isset( $session['skippedPages'] ) ) {
193 $this->skippedPages
= $session['skippedPages'];
195 $this->skippedPages
= [];
198 $lowestUnhappy = $this->getLowestUnhappy();
200 # Special case for Creative Commons partner chooser box.
201 if ( $this->request
->getVal( 'SubmitCC' ) ) {
202 $page = $this->getPageByName( 'Options' );
203 $this->output
->useShortHeader();
204 $this->output
->allowFrames();
207 return $this->finish();
210 if ( $this->request
->getVal( 'ShowCC' ) ) {
211 $page = $this->getPageByName( 'Options' );
212 $this->output
->useShortHeader();
213 $this->output
->allowFrames();
214 $this->output
->addHTML( $page->getCCDoneBox() );
216 return $this->finish();
220 $pageName = $this->request
->getVal( 'page' );
222 if ( in_array( $pageName, $this->otherPages
) ) {
225 $page = $this->getPageByName( $pageName );
228 if ( !$pageName ||
!in_array( $pageName, $this->pageSequence
) ) {
229 $pageId = $lowestUnhappy;
231 $pageId = array_search( $pageName, $this->pageSequence
);
234 # If necessary, move back to the lowest-numbered unhappy page
235 if ( $pageId > $lowestUnhappy ) {
236 $pageId = $lowestUnhappy;
237 if ( $lowestUnhappy == 0 ) {
238 # Knocked back to start, possible loss of session data.
239 $this->showSessionWarning
= true;
243 $pageName = $this->pageSequence
[$pageId];
244 $page = $this->getPageByName( $pageName );
247 # If a back button was submitted, go back without submitting the form data.
248 if ( $this->request
->wasPosted() && $this->request
->getBool( 'submit-back' ) ) {
249 if ( $this->request
->getVal( 'lastPage' ) ) {
250 $nextPage = $this->request
->getVal( 'lastPage' );
251 } elseif ( $pageId !== false ) {
253 # Skip the skipped pages
254 $nextPageId = $pageId;
258 $nextPage = $this->pageSequence
[$nextPageId];
259 } while ( isset( $this->skippedPages
[$nextPage] ) );
261 $nextPage = $this->pageSequence
[$lowestUnhappy];
264 $this->output
->redirect( $this->getUrl( [ 'page' => $nextPage ] ) );
266 return $this->finish();
270 $this->currentPageName
= $page->getName();
271 $this->startPageWrapper( $pageName );
273 if ( $page->isSlow() ) {
274 $this->disableTimeLimit();
277 $result = $page->execute();
279 $this->endPageWrapper();
281 if ( $result == 'skip' ) {
282 # Page skipped without explicit submission.
283 # Skip it when we click "back" so that we don't just go forward again.
284 $this->skippedPages
[$pageName] = true;
285 $result = 'continue';
287 unset( $this->skippedPages
[$pageName] );
290 # If it was posted, the page can request a continue to the next page.
291 if ( $result === 'continue' && !$this->output
->headerDone() ) {
292 if ( $pageId !== false ) {
293 $this->happyPages
[$pageId] = true;
296 $lowestUnhappy = $this->getLowestUnhappy();
298 if ( $this->request
->getVal( 'lastPage' ) ) {
299 $nextPage = $this->request
->getVal( 'lastPage' );
300 } elseif ( $pageId !== false ) {
301 $nextPage = $this->pageSequence
[$pageId +
1];
303 $nextPage = $this->pageSequence
[$lowestUnhappy];
306 if ( array_search( $nextPage, $this->pageSequence
) > $lowestUnhappy ) {
307 $nextPage = $this->pageSequence
[$lowestUnhappy];
310 $this->output
->redirect( $this->getUrl( [ 'page' => $nextPage ] ) );
313 return $this->finish();
317 * Find the next page in sequence that hasn't been completed
320 public function getLowestUnhappy() {
321 if ( count( $this->happyPages
) == 0 ) {
324 return max( array_keys( $this->happyPages
) ) +
1;
329 * Start the PHP session. This may be called before execute() to start the PHP session.
334 public function startSession() {
335 if ( wfIniGetBool( 'session.auto_start' ) ||
session_id() ) {
340 $this->phpErrors
= [];
341 set_error_handler( [ $this, 'errorHandler' ] );
343 session_name( 'mw_installer_session' );
345 } catch ( Exception
$e ) {
346 restore_error_handler();
349 restore_error_handler();
351 if ( $this->phpErrors
) {
359 * Get a hash of data identifying this MW installation.
361 * This is used by mw-config/index.php to prevent multiple installations of MW
362 * on the same cookie domain from interfering with each other.
366 public function getFingerprint() {
367 // Get the base URL of the installation
368 $url = $this->request
->getFullRequestURL();
369 if ( preg_match( '!^(.*\?)!', $url, $m ) ) {
373 if ( preg_match( '!^(.*)/[^/]*/[^/]*$!', $url, $m ) ) {
374 // This... seems to try to get the base path from
375 // the /mw-config/index.php. Kinda scary though?
379 return md5( serialize( [
380 'local path' => dirname( __DIR__
),
382 'version' => $GLOBALS['wgVersion']
387 * Show an error message in a box. Parameters are like wfMessage(), or
388 * alternatively, pass a Message object in.
389 * @param string|Message $msg
391 public function showError( $msg /*...*/ ) {
392 if ( !( $msg instanceof Message
) ) {
393 $args = func_get_args();
394 array_shift( $args );
395 $args = array_map( 'htmlspecialchars', $args );
396 $msg = wfMessage( $msg, $args );
398 $text = $msg->useDatabase( false )->plain();
399 $this->output
->addHTML( $this->getErrorBox( $text ) );
403 * Temporary error handler for session start debugging.
405 * @param int $errno Unused
406 * @param string $errstr
408 public function errorHandler( $errno, $errstr ) {
409 $this->phpErrors
[] = $errstr;
413 * Clean up from execute()
417 public function finish() {
418 $this->output
->output();
420 $this->session
['happyPages'] = $this->happyPages
;
421 $this->session
['skippedPages'] = $this->skippedPages
;
422 $this->session
['settings'] = $this->settings
;
424 return $this->session
;
428 * We're restarting the installation, reset the session, happyPages, etc
430 public function reset() {
432 $this->happyPages
= [];
433 $this->settings
= [];
437 * Get a URL for submission back to the same script.
439 * @param string[] $query
443 public function getUrl( $query = [] ) {
444 $url = $this->request
->getRequestURL();
445 # Remove existing query
446 $url = preg_replace( '/\?.*$/', '', $url );
449 $url .= '?' . wfArrayToCgi( $query );
456 * Get a WebInstallerPage by name.
458 * @param string $pageName
459 * @return WebInstallerPage
461 public function getPageByName( $pageName ) {
462 $pageClass = 'WebInstaller' . $pageName;
464 return new $pageClass( $this );
468 * Get a session variable.
470 * @param string $name
471 * @param array $default
475 public function getSession( $name, $default = null ) {
476 if ( !isset( $this->session
[$name] ) ) {
479 return $this->session
[$name];
484 * Set a session variable.
486 * @param string $name Key for the variable
487 * @param mixed $value
489 public function setSession( $name, $value ) {
490 $this->session
[$name] = $value;
494 * Get the next tabindex attribute value.
498 public function nextTabIndex() {
499 return $this->tabIndex++
;
503 * Initializes language-related variables.
505 public function setupLanguage() {
506 global $wgLang, $wgContLang, $wgLanguageCode;
508 if ( $this->getSession( 'test' ) === null && !$this->request
->wasPosted() ) {
509 $wgLanguageCode = $this->getAcceptLanguage();
510 $wgLang = $wgContLang = Language
::factory( $wgLanguageCode );
511 RequestContext
::getMain()->setLanguage( $wgLang );
512 $this->setVar( 'wgLanguageCode', $wgLanguageCode );
513 $this->setVar( '_UserLang', $wgLanguageCode );
515 $wgLanguageCode = $this->getVar( 'wgLanguageCode' );
516 $wgContLang = Language
::factory( $wgLanguageCode );
521 * Retrieves MediaWiki language from Accept-Language HTTP header.
525 public function getAcceptLanguage() {
526 global $wgLanguageCode, $wgRequest;
528 $mwLanguages = Language
::fetchLanguageNames();
529 $headerLanguages = array_keys( $wgRequest->getAcceptLang() );
531 foreach ( $headerLanguages as $lang ) {
532 if ( isset( $mwLanguages[$lang] ) ) {
537 return $wgLanguageCode;
541 * Called by execute() before page output starts, to show a page list.
543 * @param string $currentPageName
545 private function startPageWrapper( $currentPageName ) {
546 $s = "<div class=\"config-page-wrapper\">\n";
547 $s .= "<div class=\"config-page\">\n";
548 $s .= "<div class=\"config-page-list\"><ul>\n";
551 foreach ( $this->pageSequence
as $id => $pageName ) {
552 $happy = !empty( $this->happyPages
[$id] );
553 $s .= $this->getPageListItem(
555 $happy ||
$lastHappy == $id - 1,
564 $s .= "</ul><br/><ul>\n";
565 $s .= $this->getPageListItem( 'Restart', true, $currentPageName );
567 $s .= "</ul></div>\n";
570 // config-page-language, config-page-welcome, config-page-dbconnect, config-page-upgrade,
571 // config-page-dbsettings, config-page-name, config-page-options, config-page-install,
572 // config-page-complete, config-page-restart, config-page-readme, config-page-releasenotes,
573 // config-page-copying, config-page-upgradedoc, config-page-existingwiki
574 $s .= Html
::element( 'h2', [],
575 wfMessage( 'config-page-' . strtolower( $currentPageName ) )->text() );
577 $this->output
->addHTMLNoFlush( $s );
581 * Get a list item for the page list.
583 * @param string $pageName
584 * @param bool $enabled
585 * @param string $currentPageName
589 private function getPageListItem( $pageName, $enabled, $currentPageName ) {
590 $s = "<li class=\"config-page-list-item\">";
593 // config-page-language, config-page-welcome, config-page-dbconnect, config-page-upgrade,
594 // config-page-dbsettings, config-page-name, config-page-options, config-page-install,
595 // config-page-complete, config-page-restart, config-page-readme, config-page-releasenotes,
596 // config-page-copying, config-page-upgradedoc, config-page-existingwiki
597 $name = wfMessage( 'config-page-' . strtolower( $pageName ) )->text();
600 $query = [ 'page' => $pageName ];
602 if ( !in_array( $pageName, $this->pageSequence
) ) {
603 if ( in_array( $currentPageName, $this->pageSequence
) ) {
604 $query['lastPage'] = $currentPageName;
607 $link = Html
::element( 'a',
609 'href' => $this->getUrl( $query )
614 $link = htmlspecialchars( $name );
617 if ( $pageName == $currentPageName ) {
618 $s .= "<span class=\"config-page-current\">$link</span>";
623 $s .= Html
::element( 'span',
625 'class' => 'config-page-disabled'
637 * Output some stuff after a page is finished.
639 private function endPageWrapper() {
640 $this->output
->addHTMLNoFlush(
641 "<div class=\"visualClear\"></div>\n" .
643 "<div class=\"visualClear\"></div>\n" .
648 * Get HTML for an error box with an icon.
650 * @param string $text Wikitext, get this with wfMessage()->plain()
654 public function getErrorBox( $text ) {
655 return $this->getInfoBox( $text, 'critical-32.png', 'config-error-box' );
659 * Get HTML for a warning box with an icon.
661 * @param string $text Wikitext, get this with wfMessage()->plain()
665 public function getWarningBox( $text ) {
666 return $this->getInfoBox( $text, 'warning-32.png', 'config-warning-box' );
670 * Get HTML for an info box with an icon.
672 * @param string $text Wikitext, get this with wfMessage()->plain()
673 * @param string|bool $icon Icon name, file in mw-config/images. Default: false
674 * @param string|bool $class Additional class name to add to the wrapper div. Default: false.
678 public function getInfoBox( $text, $icon = false, $class = false ) {
679 $text = $this->parse( $text, true );
680 $icon = ( $icon == false ) ?
681 'images/info-32.png' :
683 $alt = wfMessage( 'config-information' )->text();
685 return Html
::infoBox( $text, $icon, $alt, $class );
689 * Get small text indented help for a preceding form field.
690 * Parameters like wfMessage().
695 public function getHelpBox( $msg /*, ... */ ) {
696 $args = func_get_args();
697 array_shift( $args );
698 $args = array_map( 'htmlspecialchars', $args );
699 $text = wfMessage( $msg, $args )->useDatabase( false )->plain();
700 $html = $this->parse( $text, true );
702 return "<div class=\"config-help-field-container\">\n" .
703 "<span class=\"config-help-field-hint\" title=\"" .
704 wfMessage( 'config-help-tooltip' )->escaped() . "\">" .
705 wfMessage( 'config-help' )->escaped() . "</span>\n" .
706 "<div class=\"config-help-field-data\">" . $html . "</div>\n" .
712 * @param string $msg Key for wfMessage()
714 public function showHelpBox( $msg /*, ... */ ) {
715 $args = func_get_args();
716 $html = call_user_func_array( [ $this, 'getHelpBox' ], $args );
717 $this->output
->addHTML( $html );
721 * Show a short informational message.
722 * Output looks like a list.
726 public function showMessage( $msg /*, ... */ ) {
727 $args = func_get_args();
728 array_shift( $args );
729 $html = '<div class="config-message">' .
730 $this->parse( wfMessage( $msg, $args )->useDatabase( false )->plain() ) .
732 $this->output
->addHTML( $html );
736 * @param Status $status
738 public function showStatusMessage( Status
$status ) {
739 $errors = array_merge( $status->getErrorsArray(), $status->getWarningsArray() );
740 foreach ( $errors as $error ) {
741 call_user_func_array( [ $this, 'showMessage' ], $error );
746 * Label a control by wrapping a config-input div around it and putting a
750 * @param string $forId
751 * @param string $contents
752 * @param string $helpData
755 public function label( $msg, $forId, $contents, $helpData = "" ) {
756 if ( strval( $msg ) == '' ) {
757 $labelText = ' ';
759 $labelText = wfMessage( $msg )->escaped();
762 $attributes = [ 'class' => 'config-label' ];
765 $attributes['for'] = $forId;
768 return "<div class=\"config-block\">\n" .
769 " <div class=\"config-block-label\">\n" .
776 " <div class=\"config-block-elements\">\n" .
783 * Get a labelled text box to configure a variable.
785 * @param mixed[] $params
787 * var: The variable to be configured (required)
788 * label: The message name for the label (required)
789 * attribs: Additional attributes for the input element (optional)
790 * controlName: The name for the input element (optional)
791 * value: The current value of the variable (optional)
792 * help: The html for the help text (optional)
796 public function getTextBox( $params ) {
797 if ( !isset( $params['controlName'] ) ) {
798 $params['controlName'] = 'config_' . $params['var'];
801 if ( !isset( $params['value'] ) ) {
802 $params['value'] = $this->getVar( $params['var'] );
805 if ( !isset( $params['attribs'] ) ) {
806 $params['attribs'] = [];
808 if ( !isset( $params['help'] ) ) {
809 $params['help'] = "";
814 $params['controlName'],
816 $params['controlName'],
817 30, // intended to be overridden by CSS
819 $params['attribs'] +
[
820 'id' => $params['controlName'],
821 'class' => 'config-input-text',
822 'tabindex' => $this->nextTabIndex()
830 * Get a labelled textarea to configure a variable
832 * @param mixed[] $params
834 * var: The variable to be configured (required)
835 * label: The message name for the label (required)
836 * attribs: Additional attributes for the input element (optional)
837 * controlName: The name for the input element (optional)
838 * value: The current value of the variable (optional)
839 * help: The html for the help text (optional)
843 public function getTextArea( $params ) {
844 if ( !isset( $params['controlName'] ) ) {
845 $params['controlName'] = 'config_' . $params['var'];
848 if ( !isset( $params['value'] ) ) {
849 $params['value'] = $this->getVar( $params['var'] );
852 if ( !isset( $params['attribs'] ) ) {
853 $params['attribs'] = [];
855 if ( !isset( $params['help'] ) ) {
856 $params['help'] = "";
861 $params['controlName'],
863 $params['controlName'],
867 $params['attribs'] +
[
868 'id' => $params['controlName'],
869 'class' => 'config-input-text',
870 'tabindex' => $this->nextTabIndex()
878 * Get a labelled password box to configure a variable.
880 * Implements password hiding
881 * @param mixed[] $params
883 * var: The variable to be configured (required)
884 * label: The message name for the label (required)
885 * attribs: Additional attributes for the input element (optional)
886 * controlName: The name for the input element (optional)
887 * value: The current value of the variable (optional)
888 * help: The html for the help text (optional)
892 public function getPasswordBox( $params ) {
893 if ( !isset( $params['value'] ) ) {
894 $params['value'] = $this->getVar( $params['var'] );
897 if ( !isset( $params['attribs'] ) ) {
898 $params['attribs'] = [];
901 $params['value'] = $this->getFakePassword( $params['value'] );
902 $params['attribs']['type'] = 'password';
904 return $this->getTextBox( $params );
908 * Get a labelled checkbox to configure a boolean variable.
910 * @param mixed[] $params
912 * var: The variable to be configured (required)
913 * label: The message name for the label (required)
914 * attribs: Additional attributes for the input element (optional)
915 * controlName: The name for the input element (optional)
916 * value: The current value of the variable (optional)
917 * help: The html for the help text (optional)
921 public function getCheckBox( $params ) {
922 if ( !isset( $params['controlName'] ) ) {
923 $params['controlName'] = 'config_' . $params['var'];
926 if ( !isset( $params['value'] ) ) {
927 $params['value'] = $this->getVar( $params['var'] );
930 if ( !isset( $params['attribs'] ) ) {
931 $params['attribs'] = [];
933 if ( !isset( $params['help'] ) ) {
934 $params['help'] = "";
936 if ( isset( $params['rawtext'] ) ) {
937 $labelText = $params['rawtext'];
939 $labelText = $this->parse( wfMessage( $params['label'] )->text() );
942 return "<div class=\"config-input-check\">\n" .
946 $params['controlName'],
948 $params['attribs'] +
[
949 'id' => $params['controlName'],
950 'tabindex' => $this->nextTabIndex(),
959 * Get a set of labelled radio buttons.
961 * @param mixed[] $params
963 * var: The variable to be configured (required)
964 * label: The message name for the label (required)
965 * itemLabelPrefix: The message name prefix for the item labels (required)
966 * itemLabels: List of message names to use for the item labels instead
967 * of itemLabelPrefix, keyed by values
968 * values: List of allowed values (required)
969 * itemAttribs: Array of attribute arrays, outer key is the value name (optional)
970 * commonAttribs: Attribute array applied to all items
971 * controlName: The name for the input element (optional)
972 * value: The current value of the variable (optional)
973 * help: The html for the help text (optional)
977 public function getRadioSet( $params ) {
978 $items = $this->getRadioElements( $params );
980 if ( !isset( $params['label'] ) ) {
983 $label = $params['label'];
986 if ( !isset( $params['controlName'] ) ) {
987 $params['controlName'] = 'config_' . $params['var'];
990 if ( !isset( $params['help'] ) ) {
991 $params['help'] = "";
995 foreach ( $items as $value => $item ) {
996 $s .= "<li>$item</li>\n";
1000 return $this->label( $label, $params['controlName'], $s, $params['help'] );
1004 * Get a set of labelled radio buttons. You probably want to use getRadioSet(), not this.
1010 public function getRadioElements( $params ) {
1011 if ( !isset( $params['controlName'] ) ) {
1012 $params['controlName'] = 'config_' . $params['var'];
1015 if ( !isset( $params['value'] ) ) {
1016 $params['value'] = $this->getVar( $params['var'] );
1021 foreach ( $params['values'] as $value ) {
1024 if ( isset( $params['commonAttribs'] ) ) {
1025 $itemAttribs = $params['commonAttribs'];
1028 if ( isset( $params['itemAttribs'][$value] ) ) {
1029 $itemAttribs = $params['itemAttribs'][$value] +
$itemAttribs;
1032 $checked = $value == $params['value'];
1033 $id = $params['controlName'] . '_' . $value;
1034 $itemAttribs['id'] = $id;
1035 $itemAttribs['tabindex'] = $this->nextTabIndex();
1038 Xml
::radio( $params['controlName'], $value, $checked, $itemAttribs ) .
1040 Xml
::tags( 'label', [ 'for' => $id ], $this->parse(
1041 isset( $params['itemLabels'] ) ?
1042 wfMessage( $params['itemLabels'][$value] )->plain() :
1043 wfMessage( $params['itemLabelPrefix'] . strtolower( $value ) )->plain()
1051 * Output an error or warning box using a Status object.
1053 * @param Status $status
1055 public function showStatusBox( $status ) {
1056 if ( !$status->isGood() ) {
1057 $text = $status->getWikiText();
1059 if ( $status->isOK() ) {
1060 $box = $this->getWarningBox( $text );
1062 $box = $this->getErrorBox( $text );
1065 $this->output
->addHTML( $box );
1070 * Convenience function to set variables based on form data.
1071 * Assumes that variables containing "password" in the name are (potentially
1074 * @param string[] $varNames
1075 * @param string $prefix The prefix added to variables to obtain form names
1079 public function setVarsFromRequest( $varNames, $prefix = 'config_' ) {
1082 foreach ( $varNames as $name ) {
1083 $value = $this->request
->getVal( $prefix . $name );
1084 // T32524, do not trim passwords
1085 if ( stripos( $name, 'password' ) === false ) {
1086 $value = trim( $value );
1088 $newValues[$name] = $value;
1090 if ( $value === null ) {
1092 $this->setVar( $name, false );
1094 if ( stripos( $name, 'password' ) !== false ) {
1095 $this->setPassword( $name, $value );
1097 $this->setVar( $name, $value );
1106 * Helper for Installer::docLink()
1108 * @param string $page
1112 protected function getDocUrl( $page ) {
1113 $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
1115 if ( in_array( $this->currentPageName
, $this->pageSequence
) ) {
1116 $url .= '&lastPage=' . urlencode( $this->currentPageName
);
1123 * Extension tag hook for a documentation link.
1125 * @param string $linkText
1126 * @param string[] $attribs
1127 * @param Parser $parser Unused
1131 public function docLink( $linkText, $attribs, $parser ) {
1132 $url = $this->getDocUrl( $attribs['href'] );
1134 return '<a href="' . htmlspecialchars( $url ) . '">' .
1135 htmlspecialchars( $linkText ) .
1140 * Helper for "Download LocalSettings" link on WebInstall_Complete
1142 * @param string $text Unused
1143 * @param string[] $attribs Unused
1144 * @param Parser $parser Unused
1146 * @return string Html for download link
1148 public function downloadLinkHook( $text, $attribs, $parser ) {
1149 $anchor = Html
::rawElement( 'a',
1150 [ 'href' => $this->getUrl( [ 'localsettings' => 1 ] ) ],
1151 wfMessage( 'config-download-localsettings' )->parse()
1154 return Html
::rawElement( 'div', [ 'class' => 'config-download-link' ], $anchor );
1158 * If the software package wants the LocalSettings.php file
1159 * to be placed in a specific location, override this function
1160 * (see mw-config/overrides/README) to return the path of
1161 * where the file should be saved, or false for a generic
1162 * "in the base of your install"
1165 * @return string|bool
1167 public function getLocalSettingsLocation() {
1174 public function envCheckPath() {
1175 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
1176 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
1177 // to get the path to the current script... hopefully it's reliable. SIGH
1179 if ( !empty( $_SERVER['PHP_SELF'] ) ) {
1180 $path = $_SERVER['PHP_SELF'];
1181 } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
1182 $path = $_SERVER['SCRIPT_NAME'];
1184 if ( $path === false ) {
1185 $this->showError( 'config-no-uri' );
1189 return parent
::envCheckPath();
1192 public function envPrepPath() {
1193 parent
::envPrepPath();
1194 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
1195 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
1196 // to get the path to the current script... hopefully it's reliable. SIGH
1198 if ( !empty( $_SERVER['PHP_SELF'] ) ) {
1199 $path = $_SERVER['PHP_SELF'];
1200 } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
1201 $path = $_SERVER['SCRIPT_NAME'];
1203 if ( $path !== false ) {
1204 $scriptPath = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path );
1206 $this->setVar( 'wgScriptPath', "$scriptPath" );
1207 // Update variables set from Setup.php that are derived from wgScriptPath
1208 $this->setVar( 'wgScript', "$scriptPath/index.php" );
1209 $this->setVar( 'wgLoadScript', "$scriptPath/load.php" );
1210 $this->setVar( 'wgStylePath', "$scriptPath/skins" );
1211 $this->setVar( 'wgLocalStylePath', "$scriptPath/skins" );
1212 $this->setVar( 'wgExtensionAssetsPath', "$scriptPath/extensions" );
1213 $this->setVar( 'wgUploadPath', "$scriptPath/images" );
1214 $this->setVar( 'wgResourceBasePath', "$scriptPath" );
1221 protected function envGetDefaultServer() {
1222 return WebRequest
::detectServer();
1226 * Output stylesheet for web installer pages
1228 public function outputCss() {
1229 $this->request
->response()->header( 'Content-type: text/css' );
1230 echo $this->output
->getCSS();
1236 public function getPhpErrors() {
1237 return $this->phpErrors
;