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( dirname( __FILE__
) ),
367 'version' => $GLOBALS['wgVersion']
372 * Show an error message in a box. Parameters are like wfMsg().
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 wfMsg( 'config-page-' . strtolower( $currentPageName ) ) );
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 = wfMsg( 'config-page-' . strtolower( $pageName ) );
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 wfMsgNoTrans()
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 wfMsgNoTrans()
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 wfMsgNoTrans()
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 = wfMsg( 'config-information' );
644 return Html
::infoBox( $text, $icon, $alt, $class, false );
648 * Get small text indented help for a preceding form field.
649 * Parameters like wfMsg().
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\">" . wfMsgHtml( 'config-help' ) . "</span>\n" .
663 "<span class=\"mw-help-field-data\">" . $html . "</span>\n" .
669 * @param $msg String key for wfMsg()
671 public function showHelpBox( $msg /*, ... */ ) {
672 $args = func_get_args();
673 $html = call_user_func_array( array( $this, 'getHelpBox' ), $args );
674 $this->output
->addHTML( $html );
678 * Show a short informational message.
679 * Output looks like a list.
683 public function showMessage( $msg /*, ... */ ) {
684 $args = func_get_args();
685 array_shift( $args );
686 $html = '<div class="config-message">' .
687 $this->parse( wfMsgReal( $msg, $args, false, false, false ) ) .
689 $this->output
->addHTML( $html );
693 * @param $status Status
695 public function showStatusMessage( Status
$status ) {
696 $errors = array_merge( $status->getErrorsArray(), $status->getWarningsArray() );
697 foreach ( $errors as $error ) {
698 call_user_func_array( array( $this, 'showMessage' ), $error );
703 * Label a control by wrapping a config-input div around it and putting a
709 * @param $helpData string
712 public function label( $msg, $forId, $contents, $helpData = "" ) {
713 if ( strval( $msg ) == '' ) {
714 $labelText = ' ';
716 $labelText = wfMsgHtml( $msg );
719 $attributes = array( 'class' => 'config-label' );
722 $attributes['for'] = $forId;
726 "<div class=\"config-block\">\n" .
727 " <div class=\"config-block-label\">\n" .
730 $labelText ) . "\n" .
733 " <div class=\"config-block-elements\">\n" .
740 * Get a labelled text box to configure a variable.
742 * @param $params Array
744 * var: The variable to be configured (required)
745 * label: The message name for the label (required)
746 * attribs: Additional attributes for the input element (optional)
747 * controlName: The name for the input element (optional)
748 * value: The current value of the variable (optional)
749 * help: The html for the help text (optional)
753 public function getTextBox( $params ) {
754 if ( !isset( $params['controlName'] ) ) {
755 $params['controlName'] = 'config_' . $params['var'];
758 if ( !isset( $params['value'] ) ) {
759 $params['value'] = $this->getVar( $params['var'] );
762 if ( !isset( $params['attribs'] ) ) {
763 $params['attribs'] = array();
765 if ( !isset( $params['help'] ) ) {
766 $params['help'] = "";
771 $params['controlName'],
773 $params['controlName'],
774 30, // intended to be overridden by CSS
776 $params['attribs'] +
array(
777 'id' => $params['controlName'],
778 'class' => 'config-input-text',
779 'tabindex' => $this->nextTabIndex()
787 * Get a labelled textarea to configure a variable
789 * @param $params Array
791 * var: The variable to be configured (required)
792 * label: The message name for the label (required)
793 * attribs: Additional attributes for the input element (optional)
794 * controlName: The name for the input element (optional)
795 * value: The current value of the variable (optional)
796 * help: The html for the help text (optional)
800 public function getTextArea( $params ) {
801 if ( !isset( $params['controlName'] ) ) {
802 $params['controlName'] = 'config_' . $params['var'];
805 if ( !isset( $params['value'] ) ) {
806 $params['value'] = $this->getVar( $params['var'] );
809 if ( !isset( $params['attribs'] ) ) {
810 $params['attribs'] = array();
812 if ( !isset( $params['help'] ) ) {
813 $params['help'] = "";
818 $params['controlName'],
820 $params['controlName'],
824 $params['attribs'] +
array(
825 'id' => $params['controlName'],
826 'class' => 'config-input-text',
827 'tabindex' => $this->nextTabIndex()
835 * Get a labelled password box to configure a variable.
837 * Implements password hiding
838 * @param $params Array
840 * var: The variable to be configured (required)
841 * label: The message name for the label (required)
842 * attribs: Additional attributes for the input element (optional)
843 * controlName: The name for the input element (optional)
844 * value: The current value of the variable (optional)
845 * help: The html for the help text (optional)
849 public function getPasswordBox( $params ) {
850 if ( !isset( $params['value'] ) ) {
851 $params['value'] = $this->getVar( $params['var'] );
854 if ( !isset( $params['attribs'] ) ) {
855 $params['attribs'] = array();
858 $params['value'] = $this->getFakePassword( $params['value'] );
859 $params['attribs']['type'] = 'password';
861 return $this->getTextBox( $params );
865 * Get a labelled checkbox to configure a boolean variable.
867 * @param $params Array
869 * var: The variable to be configured (required)
870 * label: The message name for the label (required)
871 * attribs: Additional attributes for the input element (optional)
872 * controlName: The name for the input element (optional)
873 * value: The current value of the variable (optional)
874 * help: The html for the help text (optional)
878 public function getCheckBox( $params ) {
879 if ( !isset( $params['controlName'] ) ) {
880 $params['controlName'] = 'config_' . $params['var'];
883 if ( !isset( $params['value'] ) ) {
884 $params['value'] = $this->getVar( $params['var'] );
887 if ( !isset( $params['attribs'] ) ) {
888 $params['attribs'] = array();
890 if ( !isset( $params['help'] ) ) {
891 $params['help'] = "";
893 if( isset( $params['rawtext'] ) ) {
894 $labelText = $params['rawtext'];
896 $labelText = $this->parse( wfMsg( $params['label'] ) );
900 "<div class=\"config-input-check\">\n" .
904 $params['controlName'],
906 $params['attribs'] +
array(
907 'id' => $params['controlName'],
908 'tabindex' => $this->nextTabIndex(),
917 * Get a set of labelled radio buttons.
919 * @param $params Array
921 * var: The variable to be configured (required)
922 * label: The message name for the label (required)
923 * itemLabelPrefix: The message name prefix for the item labels (required)
924 * values: List of allowed values (required)
925 * itemAttribs Array of attribute arrays, outer key is the value name (optional)
926 * commonAttribs Attribute array applied to all items
927 * controlName: The name for the input element (optional)
928 * value: The current value of the variable (optional)
929 * help: The html for the help text (optional)
933 public function getRadioSet( $params ) {
934 if ( !isset( $params['controlName'] ) ) {
935 $params['controlName'] = 'config_' . $params['var'];
938 if ( !isset( $params['value'] ) ) {
939 $params['value'] = $this->getVar( $params['var'] );
942 if ( !isset( $params['label'] ) ) {
945 $label = $params['label'];
947 if ( !isset( $params['help'] ) ) {
948 $params['help'] = "";
951 foreach ( $params['values'] as $value ) {
952 $itemAttribs = array();
954 if ( isset( $params['commonAttribs'] ) ) {
955 $itemAttribs = $params['commonAttribs'];
958 if ( isset( $params['itemAttribs'][$value] ) ) {
959 $itemAttribs = $params['itemAttribs'][$value] +
$itemAttribs;
962 $checked = $value == $params['value'];
963 $id = $params['controlName'] . '_' . $value;
964 $itemAttribs['id'] = $id;
965 $itemAttribs['tabindex'] = $this->nextTabIndex();
969 Xml
::radio( $params['controlName'], $value, $checked, $itemAttribs ) .
971 Xml
::tags( 'label', array( 'for' => $id ), $this->parse(
972 wfMsgNoTrans( $params['itemLabelPrefix'] . strtolower( $value ) )
979 return $this->label( $label, $params['controlName'], $s, $params['help'] );
983 * Output an error or warning box using a Status object.
985 * @param $status Status
987 public function showStatusBox( $status ) {
988 if( !$status->isGood() ) {
989 $text = $status->getWikiText();
991 if( $status->isOk() ) {
992 $box = $this->getWarningBox( $text );
994 $box = $this->getErrorBox( $text );
997 $this->output
->addHTML( $box );
1002 * Convenience function to set variables based on form data.
1003 * Assumes that variables containing "password" in the name are (potentially
1006 * @param $varNames Array
1007 * @param $prefix String: the prefix added to variables to obtain form names
1011 public function setVarsFromRequest( $varNames, $prefix = 'config_' ) {
1012 $newValues = array();
1014 foreach ( $varNames as $name ) {
1015 $value = trim( $this->request
->getVal( $prefix . $name ) );
1016 $newValues[$name] = $value;
1018 if ( $value === null ) {
1020 $this->setVar( $name, false );
1022 if ( stripos( $name, 'password' ) !== false ) {
1023 $this->setPassword( $name, $value );
1025 $this->setVar( $name, $value );
1034 * Helper for Installer::docLink()
1039 protected function getDocUrl( $page ) {
1040 $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
1042 if ( in_array( $this->currentPageName
, $this->pageSequence
) ) {
1043 $url .= '&lastPage=' . urlencode( $this->currentPageName
);
1050 * Extension tag hook for a documentation link.
1057 public function docLink( $linkText, $attribs, $parser ) {
1058 $url = $this->getDocUrl( $attribs['href'] );
1059 return '<a href="' . htmlspecialchars( $url ) . '">' .
1060 htmlspecialchars( $linkText ) .
1065 * Helper for "Download LocalSettings" link on WebInstall_Complete
1070 * @return String Html for download link
1072 public function downloadLinkHook( $text, $attribs, $parser ) {
1073 $img = Html
::element( 'img', array(
1074 'src' => '../skins/common/images/download-32.png',
1078 $anchor = Html
::rawElement( 'a',
1079 array( 'href' => $this->getURL( array( 'localsettings' => 1 ) ) ),
1080 $img . ' ' . wfMsgHtml( 'config-download-localsettings' ) );
1081 return Html
::rawElement( 'div', array( 'class' => 'config-download-link' ), $anchor );
1087 public function envCheckPath( ) {
1088 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
1089 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
1090 // to get the path to the current script... hopefully it's reliable. SIGH
1092 if ( !empty( $_SERVER['PHP_SELF'] ) ) {
1093 $path = $_SERVER['PHP_SELF'];
1094 } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
1095 $path = $_SERVER['SCRIPT_NAME'];
1097 if ($path !== false) {
1098 $uri = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path );
1099 $this->setVar( 'wgScriptPath', $uri );
1101 $this->showError( 'config-no-uri' );
1104 return parent
::envCheckPath();
1107 protected function envGetDefaultServer() {
1108 return WebRequest
::detectServer();