0d5ea576a69a42549d132ef5da3c52bae607b976
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.
58 * The main sequence of page names. These will be displayed in turn.
61 * * Add a config-page-<name> message
62 * * Add a WebInstaller_<name> class
65 public $pageSequence = array(
79 * Out of sequence pages, selectable by the user at any time.
82 protected $otherPages = array(
87 'UpgradeDoc', // Can't use Upgrade due to Upgrade step
91 * Array of pages which have declared that they have been submitted, have validated
92 * their input, and need no further processing.
95 protected $happyPages;
98 * List of "skipped" pages. These are pages that will automatically continue
99 * to the next page on any GET request. To avoid breaking the "back" button,
100 * they need to be skipped during a back operation.
103 protected $skippedPages;
106 * Flag indicating that session data may have been lost.
109 public $showSessionWarning = false;
112 * Numeric index of the page we're on
115 protected $tabIndex = 1;
118 * Name of the page we're on
121 protected $currentPageName;
126 * @param $request WebRequest
128 public function __construct( WebRequest
$request ) {
129 parent
::__construct();
130 $this->output
= new WebInstallerOutput( $this );
131 $this->request
= $request;
135 $wgParser->setHook( 'downloadlink', array( $this, 'downloadLinkHook' ) );
136 $wgParser->setHook( 'doclink', array( $this, 'docLink' ) );
142 * @param $session Array: initial session array
144 * @return Array: new session array
146 public function execute( array $session ) {
147 $this->session
= $session;
149 if ( isset( $session['settings'] ) ) {
150 $this->settings
= $session['settings'] +
$this->settings
;
154 $this->setupLanguage();
156 if( ( $this->getVar( '_InstallDone' ) ||
$this->getVar( '_UpgradeDone' ) )
157 && $this->request
->getVal( 'localsettings' ) )
159 $this->request
->response()->header( 'Content-type: application/x-httpd-php' );
160 $this->request
->response()->header(
161 'Content-Disposition: attachment; filename="LocalSettings.php"'
164 $ls = InstallerOverrides
::getLocalSettingsGenerator( $this );
165 $rightsProfile = $this->rightsProfiles
[$this->getVar( '_RightsProfile' )];
166 foreach( $rightsProfile as $group => $rightsArr ) {
167 $ls->setGroupRights( $group, $rightsArr );
170 return $this->session
;
173 $cssDir = $this->request
->getVal( 'css' );
175 $cssDir = ( $cssDir == 'rtl' ?
'rtl' : 'ltr' );
176 $this->request
->response()->header( 'Content-type: text/css' );
177 echo $this->output
->getCSS( $cssDir );
178 return $this->session
;
181 if ( isset( $session['happyPages'] ) ) {
182 $this->happyPages
= $session['happyPages'];
184 $this->happyPages
= array();
187 if ( isset( $session['skippedPages'] ) ) {
188 $this->skippedPages
= $session['skippedPages'];
190 $this->skippedPages
= array();
193 $lowestUnhappy = $this->getLowestUnhappy();
195 # Special case for Creative Commons partner chooser box.
196 if ( $this->request
->getVal( 'SubmitCC' ) ) {
197 $page = $this->getPageByName( 'Options' );
198 $this->output
->useShortHeader();
199 $this->output
->allowFrames();
201 return $this->finish();
204 if ( $this->request
->getVal( 'ShowCC' ) ) {
205 $page = $this->getPageByName( 'Options' );
206 $this->output
->useShortHeader();
207 $this->output
->allowFrames();
208 $this->output
->addHTML( $page->getCCDoneBox() );
209 return $this->finish();
213 $pageName = $this->request
->getVal( 'page' );
215 if ( in_array( $pageName, $this->otherPages
) ) {
218 $page = $this->getPageByName( $pageName );
221 if ( !$pageName ||
!in_array( $pageName, $this->pageSequence
) ) {
222 $pageId = $lowestUnhappy;
224 $pageId = array_search( $pageName, $this->pageSequence
);
227 # If necessary, move back to the lowest-numbered unhappy page
228 if ( $pageId > $lowestUnhappy ) {
229 $pageId = $lowestUnhappy;
230 if ( $lowestUnhappy == 0 ) {
231 # Knocked back to start, possible loss of session data.
232 $this->showSessionWarning
= true;
236 $pageName = $this->pageSequence
[$pageId];
237 $page = $this->getPageByName( $pageName );
240 # If a back button was submitted, go back without submitting the form data.
241 if ( $this->request
->wasPosted() && $this->request
->getBool( 'submit-back' ) ) {
242 if ( $this->request
->getVal( 'lastPage' ) ) {
243 $nextPage = $this->request
->getVal( 'lastPage' );
244 } elseif ( $pageId !== false ) {
246 # Skip the skipped pages
247 $nextPageId = $pageId;
251 $nextPage = $this->pageSequence
[$nextPageId];
252 } while( isset( $this->skippedPages
[$nextPage] ) );
254 $nextPage = $this->pageSequence
[$lowestUnhappy];
257 $this->output
->redirect( $this->getUrl( array( 'page' => $nextPage ) ) );
258 return $this->finish();
262 $this->currentPageName
= $page->getName();
263 $this->startPageWrapper( $pageName );
265 if( $page->isSlow() ) {
266 $this->disableTimeLimit();
269 $result = $page->execute();
271 $this->endPageWrapper();
273 if ( $result == 'skip' ) {
274 # Page skipped without explicit submission.
275 # Skip it when we click "back" so that we don't just go forward again.
276 $this->skippedPages
[$pageName] = true;
277 $result = 'continue';
279 unset( $this->skippedPages
[$pageName] );
282 # If it was posted, the page can request a continue to the next page.
283 if ( $result === 'continue' && !$this->output
->headerDone() ) {
284 if ( $pageId !== false ) {
285 $this->happyPages
[$pageId] = true;
288 $lowestUnhappy = $this->getLowestUnhappy();
290 if ( $this->request
->getVal( 'lastPage' ) ) {
291 $nextPage = $this->request
->getVal( 'lastPage' );
292 } elseif ( $pageId !== false ) {
293 $nextPage = $this->pageSequence
[$pageId +
1];
295 $nextPage = $this->pageSequence
[$lowestUnhappy];
298 if ( array_search( $nextPage, $this->pageSequence
) > $lowestUnhappy ) {
299 $nextPage = $this->pageSequence
[$lowestUnhappy];
302 $this->output
->redirect( $this->getUrl( array( 'page' => $nextPage ) ) );
305 return $this->finish();
309 * Find the next page in sequence that hasn't been completed
312 public function getLowestUnhappy() {
313 if ( count( $this->happyPages
) == 0 ) {
316 return max( array_keys( $this->happyPages
) ) +
1;
321 * Start the PHP session. This may be called before execute() to start the PHP session.
325 public function startSession() {
326 if( wfIniGetBool( 'session.auto_start' ) ||
session_id() ) {
331 $this->phpErrors
= array();
332 set_error_handler( array( $this, 'errorHandler' ) );
334 restore_error_handler();
336 if ( $this->phpErrors
) {
337 $this->showError( 'config-session-error', $this->phpErrors
[0] );
345 * Get a hash of data identifying this MW installation.
347 * This is used by mw-config/index.php to prevent multiple installations of MW
348 * on the same cookie domain from interfering with each other.
352 public function getFingerprint() {
353 // Get the base URL of the installation
354 $url = $this->request
->getFullRequestURL();
355 if ( preg_match( '!^(.*\?)!', $url, $m) ) {
359 if ( preg_match( '!^(.*)/[^/]*/[^/]*$!', $url, $m ) ) {
360 // This... seems to try to get the base path from
361 // the /mw-config/index.php. Kinda scary though?
364 return md5( serialize( array(
365 'local path' => dirname( __DIR__
),
367 'version' => $GLOBALS['wgVersion']
372 * Show an error message in a box. Parameters are like wfMessage().
375 public function showError( $msg /*...*/ ) {
376 $args = func_get_args();
377 array_shift( $args );
378 $args = array_map( 'htmlspecialchars', $args );
379 $msg = wfMsgReal( $msg, $args, false, false, false );
380 $this->output
->addHTML( $this->getErrorBox( $msg ) );
384 * Temporary error handler for session start debugging.
386 * @param $errstr string
388 public function errorHandler( $errno, $errstr ) {
389 $this->phpErrors
[] = $errstr;
393 * Clean up from execute()
397 public function finish() {
398 $this->output
->output();
400 $this->session
['happyPages'] = $this->happyPages
;
401 $this->session
['skippedPages'] = $this->skippedPages
;
402 $this->session
['settings'] = $this->settings
;
404 return $this->session
;
408 * We're restarting the installation, reset the session, happyPages, etc
410 public function reset() {
411 $this->session
= array();
412 $this->happyPages
= array();
413 $this->settings
= array();
417 * Get a URL for submission back to the same script.
419 * @param $query array
422 public function getUrl( $query = array() ) {
423 $url = $this->request
->getRequestURL();
424 # Remove existing query
425 $url = preg_replace( '/\?.*$/', '', $url );
428 $url .= '?' . wfArrayToCGI( $query );
435 * Get a WebInstallerPage by name.
437 * @param $pageName String
438 * @return WebInstallerPage
440 public function getPageByName( $pageName ) {
441 $pageClass = 'WebInstaller_' . $pageName;
443 return new $pageClass( $this );
447 * Get a session variable.
449 * @param $name String
453 public function getSession( $name, $default = null ) {
454 if ( !isset( $this->session
[$name] ) ) {
457 return $this->session
[$name];
462 * Set a session variable.
463 * @param $name String key for the variable
464 * @param $value Mixed
466 public function setSession( $name, $value ) {
467 $this->session
[$name] = $value;
471 * Get the next tabindex attribute value.
474 public function nextTabIndex() {
475 return $this->tabIndex++
;
479 * Initializes language-related variables.
481 public function setupLanguage() {
482 global $wgLang, $wgContLang, $wgLanguageCode;
484 if ( $this->getSession( 'test' ) === null && !$this->request
->wasPosted() ) {
485 $wgLanguageCode = $this->getAcceptLanguage();
486 $wgLang = $wgContLang = Language
::factory( $wgLanguageCode );
487 $this->setVar( 'wgLanguageCode', $wgLanguageCode );
488 $this->setVar( '_UserLang', $wgLanguageCode );
490 $wgLanguageCode = $this->getVar( 'wgLanguageCode' );
491 $wgContLang = Language
::factory( $wgLanguageCode );
496 * Retrieves MediaWiki language from Accept-Language HTTP header.
500 public function getAcceptLanguage() {
501 global $wgLanguageCode, $wgRequest;
503 $mwLanguages = Language
::fetchLanguageNames();
504 $headerLanguages = array_keys( $wgRequest->getAcceptLang() );
506 foreach ( $headerLanguages as $lang ) {
507 if ( isset( $mwLanguages[$lang] ) ) {
512 return $wgLanguageCode;
516 * Called by execute() before page output starts, to show a page list.
518 * @param $currentPageName String
520 private function startPageWrapper( $currentPageName ) {
521 $s = "<div class=\"config-page-wrapper\">\n";
522 $s .= "<div class=\"config-page\">\n";
523 $s .= "<div class=\"config-page-list\"><ul>\n";
526 foreach ( $this->pageSequence
as $id => $pageName ) {
527 $happy = !empty( $this->happyPages
[$id] );
528 $s .= $this->getPageListItem(
530 $happy ||
$lastHappy == $id - 1,
539 $s .= "</ul><br/><ul>\n";
540 $s .= $this->getPageListItem( 'Restart', true, $currentPageName );
541 $s .= "</ul></div>\n"; // end list pane
542 $s .= Html
::element( 'h2', array(),
543 wfMessage( 'config-page-' . strtolower( $currentPageName ) )->text() );
545 $this->output
->addHTMLNoFlush( $s );
549 * Get a list item for the page list.
551 * @param $pageName String
552 * @param $enabled Boolean
553 * @param $currentPageName String
557 private function getPageListItem( $pageName, $enabled, $currentPageName ) {
558 $s = "<li class=\"config-page-list-item\">";
559 $name = wfMessage( 'config-page-' . strtolower( $pageName ) )->text();
562 $query = array( 'page' => $pageName );
564 if ( !in_array( $pageName, $this->pageSequence
) ) {
565 if ( in_array( $currentPageName, $this->pageSequence
) ) {
566 $query['lastPage'] = $currentPageName;
569 $link = Html
::element( 'a',
571 'href' => $this->getUrl( $query )
576 $link = htmlspecialchars( $name );
579 if ( $pageName == $currentPageName ) {
580 $s .= "<span class=\"config-page-current\">$link</span>";
585 $s .= Html
::element( 'span',
587 'class' => 'config-page-disabled'
599 * Output some stuff after a page is finished.
601 private function endPageWrapper() {
602 $this->output
->addHTMLNoFlush(
603 "<div class=\"visualClear\"></div>\n" .
605 "<div class=\"visualClear\"></div>\n" .
610 * Get HTML for an error box with an icon.
612 * @param $text String: wikitext, get this with wfMessage()->plain()
616 public function getErrorBox( $text ) {
617 return $this->getInfoBox( $text, 'critical-32.png', 'config-error-box' );
621 * Get HTML for a warning box with an icon.
623 * @param $text String: wikitext, get this with wfMessage()->plain()
627 public function getWarningBox( $text ) {
628 return $this->getInfoBox( $text, 'warning-32.png', 'config-warning-box' );
632 * Get HTML for an info box with an icon.
634 * @param $text String: wikitext, get this with wfMessage()->plain()
635 * @param $icon String: icon name, file in skins/common/images
636 * @param $class String: additional class name to add to the wrapper div
640 public function getInfoBox( $text, $icon = false, $class = false ) {
641 $text = $this->parse( $text, true );
642 $icon = ( $icon == false ) ?
'../skins/common/images/info-32.png' : '../skins/common/images/'.$icon;
643 $alt = wfMessage( 'config-information' )->text();
644 return Html
::infoBox( $text, $icon, $alt, $class, false );
648 * Get small text indented help for a preceding form field.
649 * Parameters like wfMessage().
654 public function getHelpBox( $msg /*, ... */ ) {
655 $args = func_get_args();
656 array_shift( $args );
657 $args = array_map( 'htmlspecialchars', $args );
658 $text = wfMsgReal( $msg, $args, false, false, false );
659 $html = $this->parse( $text, true );
661 return "<div class=\"mw-help-field-container\">\n" .
662 "<span class=\"mw-help-field-hint\">" . wfMessage( 'config-help' )->escaped() .
664 "<span class=\"mw-help-field-data\">" . $html . "</span>\n" .
670 * @param $msg String key for wfMessage()
672 public function showHelpBox( $msg /*, ... */ ) {
673 $args = func_get_args();
674 $html = call_user_func_array( array( $this, 'getHelpBox' ), $args );
675 $this->output
->addHTML( $html );
679 * Show a short informational message.
680 * Output looks like a list.
684 public function showMessage( $msg /*, ... */ ) {
685 $args = func_get_args();
686 array_shift( $args );
687 $html = '<div class="config-message">' .
688 $this->parse( wfMsgReal( $msg, $args, false, false, false ) ) .
690 $this->output
->addHTML( $html );
694 * @param $status Status
696 public function showStatusMessage( Status
$status ) {
697 $errors = array_merge( $status->getErrorsArray(), $status->getWarningsArray() );
698 foreach ( $errors as $error ) {
699 call_user_func_array( array( $this, 'showMessage' ), $error );
704 * Label a control by wrapping a config-input div around it and putting a
710 * @param $helpData string
713 public function label( $msg, $forId, $contents, $helpData = "" ) {
714 if ( strval( $msg ) == '' ) {
715 $labelText = ' ';
717 $labelText = wfMessage( $msg )->escaped();
720 $attributes = array( 'class' => 'config-label' );
723 $attributes['for'] = $forId;
727 "<div class=\"config-block\">\n" .
728 " <div class=\"config-block-label\">\n" .
731 $labelText ) . "\n" .
734 " <div class=\"config-block-elements\">\n" .
741 * Get a labelled text box to configure a variable.
743 * @param $params Array
745 * var: The variable to be configured (required)
746 * label: The message name for the label (required)
747 * attribs: Additional attributes for the input element (optional)
748 * controlName: The name for the input element (optional)
749 * value: The current value of the variable (optional)
750 * help: The html for the help text (optional)
754 public function getTextBox( $params ) {
755 if ( !isset( $params['controlName'] ) ) {
756 $params['controlName'] = 'config_' . $params['var'];
759 if ( !isset( $params['value'] ) ) {
760 $params['value'] = $this->getVar( $params['var'] );
763 if ( !isset( $params['attribs'] ) ) {
764 $params['attribs'] = array();
766 if ( !isset( $params['help'] ) ) {
767 $params['help'] = "";
772 $params['controlName'],
774 $params['controlName'],
775 30, // intended to be overridden by CSS
777 $params['attribs'] +
array(
778 'id' => $params['controlName'],
779 'class' => 'config-input-text',
780 'tabindex' => $this->nextTabIndex()
788 * Get a labelled textarea to configure a variable
790 * @param $params Array
792 * var: The variable to be configured (required)
793 * label: The message name for the label (required)
794 * attribs: Additional attributes for the input element (optional)
795 * controlName: The name for the input element (optional)
796 * value: The current value of the variable (optional)
797 * help: The html for the help text (optional)
801 public function getTextArea( $params ) {
802 if ( !isset( $params['controlName'] ) ) {
803 $params['controlName'] = 'config_' . $params['var'];
806 if ( !isset( $params['value'] ) ) {
807 $params['value'] = $this->getVar( $params['var'] );
810 if ( !isset( $params['attribs'] ) ) {
811 $params['attribs'] = array();
813 if ( !isset( $params['help'] ) ) {
814 $params['help'] = "";
819 $params['controlName'],
821 $params['controlName'],
825 $params['attribs'] +
array(
826 'id' => $params['controlName'],
827 'class' => 'config-input-text',
828 'tabindex' => $this->nextTabIndex()
836 * Get a labelled password box to configure a variable.
838 * Implements password hiding
839 * @param $params Array
841 * var: The variable to be configured (required)
842 * label: The message name for the label (required)
843 * attribs: Additional attributes for the input element (optional)
844 * controlName: The name for the input element (optional)
845 * value: The current value of the variable (optional)
846 * help: The html for the help text (optional)
850 public function getPasswordBox( $params ) {
851 if ( !isset( $params['value'] ) ) {
852 $params['value'] = $this->getVar( $params['var'] );
855 if ( !isset( $params['attribs'] ) ) {
856 $params['attribs'] = array();
859 $params['value'] = $this->getFakePassword( $params['value'] );
860 $params['attribs']['type'] = 'password';
862 return $this->getTextBox( $params );
866 * Get a labelled checkbox to configure a boolean variable.
868 * @param $params Array
870 * var: The variable to be configured (required)
871 * label: The message name for the label (required)
872 * attribs: Additional attributes for the input element (optional)
873 * controlName: The name for the input element (optional)
874 * value: The current value of the variable (optional)
875 * help: The html for the help text (optional)
879 public function getCheckBox( $params ) {
880 if ( !isset( $params['controlName'] ) ) {
881 $params['controlName'] = 'config_' . $params['var'];
884 if ( !isset( $params['value'] ) ) {
885 $params['value'] = $this->getVar( $params['var'] );
888 if ( !isset( $params['attribs'] ) ) {
889 $params['attribs'] = array();
891 if ( !isset( $params['help'] ) ) {
892 $params['help'] = "";
894 if( isset( $params['rawtext'] ) ) {
895 $labelText = $params['rawtext'];
897 $labelText = $this->parse( wfMessage( $params['label'] )->text() );
901 "<div class=\"config-input-check\">\n" .
905 $params['controlName'],
907 $params['attribs'] +
array(
908 'id' => $params['controlName'],
909 'tabindex' => $this->nextTabIndex(),
918 * Get a set of labelled radio buttons.
920 * @param $params Array
922 * var: The variable to be configured (required)
923 * label: The message name for the label (required)
924 * itemLabelPrefix: The message name prefix for the item labels (required)
925 * values: List of allowed values (required)
926 * itemAttribs Array of attribute arrays, outer key is the value name (optional)
927 * commonAttribs Attribute array applied to all items
928 * controlName: The name for the input element (optional)
929 * value: The current value of the variable (optional)
930 * help: The html for the help text (optional)
934 public function getRadioSet( $params ) {
935 if ( !isset( $params['controlName'] ) ) {
936 $params['controlName'] = 'config_' . $params['var'];
939 if ( !isset( $params['value'] ) ) {
940 $params['value'] = $this->getVar( $params['var'] );
943 if ( !isset( $params['label'] ) ) {
946 $label = $params['label'];
948 if ( !isset( $params['help'] ) ) {
949 $params['help'] = "";
952 foreach ( $params['values'] as $value ) {
953 $itemAttribs = array();
955 if ( isset( $params['commonAttribs'] ) ) {
956 $itemAttribs = $params['commonAttribs'];
959 if ( isset( $params['itemAttribs'][$value] ) ) {
960 $itemAttribs = $params['itemAttribs'][$value] +
$itemAttribs;
963 $checked = $value == $params['value'];
964 $id = $params['controlName'] . '_' . $value;
965 $itemAttribs['id'] = $id;
966 $itemAttribs['tabindex'] = $this->nextTabIndex();
970 Xml
::radio( $params['controlName'], $value, $checked, $itemAttribs ) .
972 Xml
::tags( 'label', array( 'for' => $id ), $this->parse(
973 wfMessage( $params['itemLabelPrefix'] . strtolower( $value ) )->plain()
980 return $this->label( $label, $params['controlName'], $s, $params['help'] );
984 * Output an error or warning box using a Status object.
986 * @param $status Status
988 public function showStatusBox( $status ) {
989 if( !$status->isGood() ) {
990 $text = $status->getWikiText();
992 if( $status->isOk() ) {
993 $box = $this->getWarningBox( $text );
995 $box = $this->getErrorBox( $text );
998 $this->output
->addHTML( $box );
1003 * Convenience function to set variables based on form data.
1004 * Assumes that variables containing "password" in the name are (potentially
1007 * @param $varNames Array
1008 * @param $prefix String: the prefix added to variables to obtain form names
1012 public function setVarsFromRequest( $varNames, $prefix = 'config_' ) {
1013 $newValues = array();
1015 foreach ( $varNames as $name ) {
1016 $value = trim( $this->request
->getVal( $prefix . $name ) );
1017 $newValues[$name] = $value;
1019 if ( $value === null ) {
1021 $this->setVar( $name, false );
1023 if ( stripos( $name, 'password' ) !== false ) {
1024 $this->setPassword( $name, $value );
1026 $this->setVar( $name, $value );
1035 * Helper for Installer::docLink()
1040 protected function getDocUrl( $page ) {
1041 $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
1043 if ( in_array( $this->currentPageName
, $this->pageSequence
) ) {
1044 $url .= '&lastPage=' . urlencode( $this->currentPageName
);
1051 * Extension tag hook for a documentation link.
1058 public function docLink( $linkText, $attribs, $parser ) {
1059 $url = $this->getDocUrl( $attribs['href'] );
1060 return '<a href="' . htmlspecialchars( $url ) . '">' .
1061 htmlspecialchars( $linkText ) .
1066 * Helper for "Download LocalSettings" link on WebInstall_Complete
1071 * @return String Html for download link
1073 public function downloadLinkHook( $text, $attribs, $parser ) {
1074 $img = Html
::element( 'img', array(
1075 'src' => '../skins/common/images/download-32.png',
1079 $anchor = Html
::rawElement( 'a',
1080 array( 'href' => $this->getURL( array( 'localsettings' => 1 ) ) ),
1081 $img . ' ' . wfMessage( 'config-download-localsettings' )->escaped() );
1082 return Html
::rawElement( 'div', array( 'class' => 'config-download-link' ), $anchor );
1088 public function envCheckPath( ) {
1089 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
1090 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
1091 // to get the path to the current script... hopefully it's reliable. SIGH
1093 if ( !empty( $_SERVER['PHP_SELF'] ) ) {
1094 $path = $_SERVER['PHP_SELF'];
1095 } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
1096 $path = $_SERVER['SCRIPT_NAME'];
1098 if ($path !== false) {
1099 $uri = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path );
1100 $this->setVar( 'wgScriptPath', $uri );
1102 $this->showError( 'config-no-uri' );
1105 return parent
::envCheckPath();
1108 protected function envGetDefaultServer() {
1109 return WebRequest
::detectServer();