Page MenuHomePhabricator

Automatically Redirect to mw-config when no LocalSettings.php is found.
Closed, DeclinedPublic

Description

Feature Request: Automatically Redirect to mw-config when no LocalSettings.php is found. Since I can not access the git environment, I am submitting this Task (not a bug). You can push this to Gerrit if you want it. This is my NoLocalSettings.php with modifications:

<?php
// @codingStandardsIgnoreFile
/**
 * Automatic redirect used when there is no LocalSettings.php file.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 * http://www.gnu.org/copyleft/gpl.html
 *
 * @file
 * @ingroup Templates
 */

if ( !defined( 'MEDIAWIKI' ) ) {
	die( "NoLocalSettings.php is not a valid MediaWiki entry point\n" );
}

if ( !isset( $wgVersion ) ) {
	$wgVersion = 'VERSION';
}

# bug 30219 : can not use pathinfo() on URLs since slashes do not match
$matches = array();
$ext = 'php';
$path = "http://".$_SERVER["SERVER_NAME"]."/";
foreach ( array_filter( explode( '/', $_SERVER['PHP_SELF'] ) ) as $part ) {
	if ( !preg_match( '/\.(php5?)$/', $part, $matches ) ) {
		$path .= "$part/";
	} else {
		$ext = $matches[1] == 'php5' ? 'php5' : 'php';
	}
}

# Check to see if the installer is running
if ( !function_exists( 'session_name' ) ) {
	$installerStarted = false;
} else {
	session_name( 'mw_installer_session' );
	$oldReporting = error_reporting( E_ALL & ~E_NOTICE );
	$success = session_start();
	error_reporting( $oldReporting );
	$installerStarted = ( $success && isset( $_SESSION['installData'] ) );
}

# Do an automatic redirect for the browser
header("Location: ". htmlspecialchars( $path ) . "mw-config/index." . htmlspecialchars( $ext )."",true,302);
?>

Event Timeline

DSCrowned raised the priority of this task from to Lowest.
DSCrowned updated the task description. (Show Details)
DSCrowned added a subscriber: DSCrowned.

I recommend that this bit be deleted. It has no use with my version of this file:

# Check to see if the installer is running
if ( !function_exists( 'session_name' ) ) {
	$installerStarted = false;
} else {
	session_name( 'mw_installer_session' );
	$oldReporting = error_reporting( E_ALL & ~E_NOTICE );
	$success = session_start();
	error_reporting( $oldReporting );
	$installerStarted = ( $success && isset( $_SESSION['installData'] ) );
}
Aklapper renamed this task from Feature Request: Automatically Redirect to mw-config when no LocalSettings.php is found. to Automatically Redirect to mw-config when no LocalSettings.php is found..Mar 23 2015, 9:45 AM

Yep, I have tried that link, and submitted my patch. Thanks!

Yep, I have tried that link, and submitted my patch.

Where exactly? (Also see mw:Gerrit/Commit message guidelines)

Whoops. I can not find it. There could be something wrong. In the meantime, I suggest you should use the code above and review it.

Code review happens in gerrit.wikimedia.org :)

Change 222944 had a related patch set uploaded (by Paladox):
Automaticaly go to mw-config if no localsettings.php exists

https://gerrit.wikimedia.org/r/222944

Is this actually a good idea? Having the two pages separate ensures that if a user uploads LocalSettings.php wrong, they won't get confused about if they're just going to the wrong url.

I have blocked the patch due to lack of consensus. Once consensus is reached either way, the patch should be abandoned or merged.

saper changed the task status from Open to Stalled.Oct 24 2015, 3:28 AM
saper moved this task from General to In progress on the MediaWiki-Installer board.
saper added a subscriber: saper.
demon claimed this task.
demon added a subscriber: demon.

Is this actually a good idea? Having the two pages separate ensures that if a user uploads LocalSettings.php wrong, they won't get confused about if they're just going to the wrong url.

No, I don't think it is a good idea to silently redirect. Also, we've made it very clear over the years that deleting the /mw-config/ directory is perfectly harmless after you've completed your install.

I'm declining this task and the associated patch.

Change 222944 abandoned by Chad:
Automatically go to mw-config if no localsettings.php exists

Reason:
Per the linked task and Daniel above, there's no consensus for this (in fact, I'm convinced it's a pretty bad behavior to do). Abandoning.

https://gerrit.wikimedia.org/r/222944