r111151 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111150‎ | r111151 | r111152 >
Date:12:55, 10 February 2012
Author:cneubauer
Status:deferred
Tags:
Comment:
Fix some of the file/directory checks. Sort files before displaying them to the user.

Patches from Drzraf2 from the extension talk page. Thanks!
Modified paths:
  • /trunk/extensions/UploadLocal/UploadLocalDirectory.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadLocal/UploadLocalDirectory.php
@@ -133,8 +133,7 @@
134134 }
135135
136136 function getFilenamesOfFilesInDirectory($directory) {
137 - if (!is_dir($directory)) return array();
138 - if ($directory[strlen($directory)-1] !== '/') $directory .= '/';
 137+ if (! is_dir($directory) || ! is_readable($directory)) return array();
139138 $dh = opendir($directory);
140139 $filenames = array();
141140 # Make sure the handle opens correctly
@@ -144,13 +143,14 @@
145144 while (($file = readdir($dh)) !== false) {
146145 if ($file == '.' || $file == '..') continue;
147146 // check if it's a directory
148 - if (is_dir($directory . $file)) continue;
 147+ if (is_dir($directory . '/' . $file)) continue;
149148 // check if it's a hidden file - regexp: /\.[^.]+/
150149 if ($file[0] == '.' && strpos($file,'.',1) === false) {
151150 continue;
152151 }
153152 $filenames[] = $file;
154153 }
 154+ sort($filenames);
155155 closedir($dh);
156156 return $filenames;
157157 }

Status & tagging log