r70711 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70710‎ | r70711 | r70712 >
Date:16:06, 8 August 2010
Author:demon
Status:resolved (Comments)
Tags:
Comment:
Greatly simplify path and extension detection for NoLocalSettings.php. Fixes bug 21215.
Modified paths:
  • /trunk/phase3/includes/templates/NoLocalSettings.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/templates/NoLocalSettings.php
@@ -7,32 +7,9 @@
88 if ( !isset( $wgVersion ) ) {
99 $wgVersion = 'VERSION';
1010 }
11 -
12 -$scriptName = $_SERVER['SCRIPT_NAME'];
13 -$ext = substr( $scriptName, strrpos( $scriptName, "." ) + 1 );
14 -$path = '';
15 -# Add any directories in the main folder that could contain an entrypoint (even possibly).
16 -# We cannot just do a dir listing here, as we do not know where it is yet
17 -# These must not also be the names of subfolders that may contain an entrypoint
18 -$topdirs = array( 'extensions', 'includes' );
19 -foreach( $topdirs as $dir ){
20 - # Check whether a directory by this name is in the path
21 - if( strrpos( $scriptName, "/" . $dir . "/" ) ){
22 - # If so, check whether it is the right folder
23 - # First, get the number of directories up it is (to generate path)
24 - $numToGoUp = substr_count( substr( $scriptName, strrpos( $scriptName, "/" . $dir . "/" ) + 1 ), "/" );
25 - # And generate the path using ..'s
26 - for( $i = 0; $i < $numToGoUp; $i++ ){
27 - $realPath = "../" . $realPath;
28 - }
29 - # Checking existance (using the image here as it is something not likely to change, and to always be here)
30 - if( file_exists( $realPath . "skins/common/images/mediawiki.png" ) ) {
31 - # If so, get the path that we can use in this file, and stop looking
32 - $path = substr( $scriptName, 0, strrpos( $scriptName, "/" . $dir . "/" ) + 1 );
33 - break;
34 - }
35 - }
36 -}
 11+$script = $_SERVER['SCRIPT_NAME'];
 12+$path = pathinfo( $script, PATHINFO_DIRNAME ) . '/';
 13+$ext = pathinfo( $script, PATHINFO_EXTENSION );
3714 ?>
3815 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3916 <html xmlns='http://www.w3.org/1999/xhtml' lang='en'>

Follow-up revisions

RevisionCommit summaryAuthorDate
r70713Followup r70711, release notesdemon16:21, 8 August 2010
r94171(bug 30219) NoLocalSettings.php broken on Windows servers. Per Tim on r70711,...demon17:28, 10 August 2011

Comments

#Comment by Siebrand (talk | contribs)   16:16, 8 August 2010

RELEASE-NOTES update missing.

#Comment by Tim Starling (talk | contribs)   12:40, 4 August 2011

Doesn't work on windows: pathinfo() can't be used for URLs because they have slashes not backslashes.

#Comment by 😂 (talk | contribs)   16:51, 16 August 2011

Fixed in r94171. Not perfect still, but better. Setting this back to new.

#Comment by Tim Starling (talk | contribs)   12:41, 4 August 2011

Status & tagging log