From d6e6b308c573585072d61a0cc12d6901435c6fea Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Fri, 9 Oct 2015 10:31:17 +0100 Subject: [PATCH] MDL-50788 classloader: Prevent cryptic errors on unreadable classes dir Do not attempt to read an unreadable directory because previously the generated errors were hard to fathom. Thanks to James McQuillan for the basis of the patch. --- lib/classes/component.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/classes/component.php b/lib/classes/component.php index f22d82001db..8eefdcc3699 100644 --- a/lib/classes/component.php +++ b/lib/classes/component.php @@ -647,6 +647,13 @@ $cache = '.var_export($cache, true).'; return; } + if (!is_readable($fulldir)) { + // TODO: MDL-51711 We should generate some diagnostic debugging information in this case + // because its pretty likely to lead to a missing class error further down the line. + // But our early setup code can't handle errors this early at the moment. + return; + } + $items = new \DirectoryIterator($fulldir); foreach ($items as $item) { if ($item->isDot()) {