Skip to content

Commit

Permalink
Fix issue #685 with Modules.php fatal error on 'check for new modules…
Browse files Browse the repository at this point in the history
…' when module directory is not readable by php.
  • Loading branch information
ryancramerdesign committed Sep 26, 2014
1 parent 17e0ef7 commit f50a1ba
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions wire/core/Modules.php
Expand Up @@ -684,9 +684,15 @@ protected function findModuleFiles($path, $readCache = false, $level = 0) {
}

$files = array();
$dir = new DirectoryIterator($path);

foreach($dir as $file) {
try {
$dir = new DirectoryIterator($path);
} catch(Exception $e) {
$this->error($e->getMessage());
$dir = null;
}

if($dir) foreach($dir as $file) {

if($file->isDot()) continue;

Expand Down Expand Up @@ -716,11 +722,9 @@ protected function findModuleFiles($path, $readCache = false, $level = 0) {
$files[] = str_replace($startPath, '', $pathname);
}

if($level == 0) {
if($level == 0 && $dir !== null) {
if($cache) $cache->save($cacheName, implode("\n", $files), WireCache::expireNever);
//@file_put_contents($cacheFilename, implode("\n", $files), LOCK_EX); // remove LOCK_EX ?
}
//if($config->chmodFile) @chmod($cacheFilename, octdec($config->chmodFile));

return $files;
}
Expand Down

0 comments on commit f50a1ba

Please sign in to comment.