registration: Fix caching of load_composer_autoloader
authorKunal Mehta <legoktm@member.fsf.org>
Sat, 23 Sep 2017 05:20:16 +0000 (22:20 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Sat, 23 Sep 2017 05:20:16 +0000 (22:20 -0700)
Move the file_exists() check out of the extension processor and into the
extension registry so that it is evaluated at run time instead of during
caching. The prior way is problematic since we don't invalidate the
cache if the existence of the file were to change.

Bug: T176534
Change-Id: I98e4ffdfac9f98397a103966824519afe1375356

includes/registration/ExtensionProcessor.php
includes/registration/ExtensionRegistry.php

index ce262bd..ffc7a7e 100644 (file)
@@ -520,10 +520,7 @@ class ExtensionProcessor implements Processor {
        public function getExtraAutoloaderPaths( $dir, array $info ) {
                $paths = [];
                if ( isset( $info['load_composer_autoloader'] ) && $info['load_composer_autoloader'] === true ) {
        public function getExtraAutoloaderPaths( $dir, array $info ) {
                $paths = [];
                if ( isset( $info['load_composer_autoloader'] ) && $info['load_composer_autoloader'] === true ) {
-                       $path = "$dir/vendor/autoload.php";
-                       if ( file_exists( $path ) ) {
-                               $paths[] = $path;
-                       }
+                       $paths[] = "$dir/vendor/autoload.php";
                }
                return $paths;
        }
                }
                return $paths;
        }
index bf33c6c..740fed4 100644 (file)
@@ -319,7 +319,9 @@ class ExtensionRegistry {
                        define( $name, $val );
                }
                foreach ( $info['autoloaderPaths'] as $path ) {
                        define( $name, $val );
                }
                foreach ( $info['autoloaderPaths'] as $path ) {
-                       require_once $path;
+                       if ( file_exists( $path ) ) {
+                               require_once $path;
+                       }
                }
 
                $this->loaded += $info['credits'];
                }
 
                $this->loaded += $info['credits'];