From 3d8eb11e7c29578810a028788983c891832be444 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Fri, 22 Mar 2013 18:53:51 +0100 Subject: [PATCH] Installer: Check if /extensions is readable and a directory Also close the dirhandler and fix one return value bug: 46447 Change-Id: I0abe540d66375e6833640bb234e62b6cc902beb0 --- includes/installer/Installer.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 7ff1ff5a9d..8aee15c817 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -1320,13 +1320,16 @@ abstract class Installer { */ public function findExtensions() { if( $this->getVar( 'IP' ) === null ) { - return false; + return array(); } - $exts = array(); $extDir = $this->getVar( 'IP' ) . '/extensions'; - $dh = opendir( $extDir ); + if ( !is_readable( $extDir ) || !is_dir( $extDir ) ) { + return array(); + } + $dh = opendir( $extDir ); + $exts = array(); while ( ( $file = readdir( $dh ) ) !== false ) { if( !is_dir( "$extDir/$file" ) ) { continue; @@ -1335,6 +1338,7 @@ abstract class Installer { $exts[] = $file; } } + closedir( $dh ); natcasesort( $exts ); return $exts; -- 2.20.1