diff --git a/core/lib/Drupal/Component/Discovery/YamlDiscovery.php b/core/lib/Drupal/Component/Discovery/YamlDiscovery.php index 4d00f44..ae9137b 100644 --- a/core/lib/Drupal/Component/Discovery/YamlDiscovery.php +++ b/core/lib/Drupal/Component/Discovery/YamlDiscovery.php @@ -49,8 +49,16 @@ public function findAll() { $all = array(); foreach ($this->findFiles() as $provider => $file) { // If a file is empty or its contents are commented out, return an empty - // array instead of NULL for type consistency. - $all[$provider] = Yaml::decode(file_get_contents($file)) ?: array(); + // array instead of NULL for type consistency. Do not use a ternary + // operator, as those can become very slow with large amounts of data. See + // http://fabien.potencier.org/article/48/the-php-ternary-operator-fast-or-not. + $contents = Yaml::decode(file_get_contents($file)); + if (!is_null($contents)) { + $all[$provider] = $contents; + } + else { + $all[$provider] = []; + } } return $all;