MDL-55283 javascript: Check dir is readable before traversing them
authorAndrew Nicols <andrew@nicols.co.uk>
Wed, 20 Jul 2016 04:06:19 +0000 (12:06 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Wed, 20 Jul 2016 04:16:13 +0000 (12:16 +0800)
lib/classes/requirejs.php

index ebe4e6f..6c75cc2 100644 (file)
@@ -108,6 +108,11 @@ class core_requirejs {
             if ($debug) {
                 $srcdir = $dir . '/src';
             }
+            if (!is_dir($srcdir) || !is_readable($srcdir)) {
+                // This is probably an empty amd directory without src or build.
+                // Skip it - RecursiveDirectoryIterator fatals if the directory is not readable as an iterator.
+                continue;
+            }
             $items = new RecursiveDirectoryIterator($srcdir);
             foreach ($items as $item) {
                 $extension = $item->getExtension();