From: umherirrender Date: Wed, 27 Mar 2013 07:14:01 +0000 (+0100) Subject: Check return value of dir() in Skin.php X-Git-Tag: 1.31.0-rc.0~20212 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=cd2eb4e113d9269b4a0200c9ac0618023fa10dcb;p=lhc%2Fweb%2Fwiklou.git Check return value of dir() in Skin.php This avoids a fatal, when something is wrong with $wgStyleDirectory or the directory referred there. PHP Fatal error: Call to a member function read() on a non-object in Skin.php bug: 42167 Change-Id: I3d63cb984bc2aa0f85ade04607862c639ba51fdb --- diff --git a/includes/Skin.php b/includes/Skin.php index a34afb68c5..e5aedd9eed 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -56,17 +56,19 @@ abstract class Skin extends ContextSource { $skinDir = dir( $wgStyleDirectory ); - # while code from www.php.net - while ( false !== ( $file = $skinDir->read() ) ) { - // Skip non-PHP files, hidden files, and '.dep' includes - $matches = array(); - - if ( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) { - $aSkin = $matches[1]; - $wgValidSkinNames[strtolower( $aSkin )] = $aSkin; + if ( $skinDir !== false && $skinDir !== null ) { + # while code from www.php.net + while ( false !== ( $file = $skinDir->read() ) ) { + // Skip non-PHP files, hidden files, and '.dep' includes + $matches = array(); + + if ( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) { + $aSkin = $matches[1]; + $wgValidSkinNames[strtolower( $aSkin )] = $aSkin; + } } + $skinDir->close(); } - $skinDir->close(); $skinsInitialised = true; wfProfileOut( __METHOD__ . '-init' ); }