Skip to content

Commit

Permalink
MDL-50788 classloader: Prevent cryptic errors on unreadable classes dir
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
danpoltawski committed Oct 9, 2015
1 parent 74fad2c commit 0496ac6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/classes/component.php
Expand Up @@ -651,6 +651,13 @@ protected static function load_classes($component, $fulldir, $namespace = '') {
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()) {
Expand Down

0 comments on commit 0496ac6

Please sign in to comment.