diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-01-03 18:31:35 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2017-01-03 19:00:05 +0100 |
commit | 8070ccc6f7cad34ec3ea940de0933f3193ef1ca9 (patch) | |
tree | fb1202911fc5c22b2a936ab65caad192517f2dd4 /lib/composer | |
parent | 5b0956559415bc3a82e78f8e5fb76a3280866ee3 (diff) | |
download | nextcloud-server-8070ccc6f7cad34ec3ea940de0933f3193ef1ca9.tar.gz nextcloud-server-8070ccc6f7cad34ec3ea940de0933f3193ef1ca9.zip |
update autoloader
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib/composer')
-rw-r--r-- | lib/composer/composer/ClassLoader.php | 36 | ||||
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 1 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 1 |
3 files changed, 31 insertions, 7 deletions
diff --git a/lib/composer/composer/ClassLoader.php b/lib/composer/composer/ClassLoader.php index ac67d302a18..4626994fd4d 100644 --- a/lib/composer/composer/ClassLoader.php +++ b/lib/composer/composer/ClassLoader.php @@ -55,6 +55,7 @@ class ClassLoader private $classMap = array(); private $classMapAuthoritative = false; private $missingClasses = array(); + private $apcuPrefix; public function getPrefixes() { @@ -272,6 +273,26 @@ class ClassLoader } /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** * Registers this instance as an autoloader. * * @param bool $prepend Whether to prepend the autoloader or not @@ -313,11 +334,6 @@ class ClassLoader */ public function findFile($class) { - // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 - if ('\\' == $class[0]) { - $class = substr($class, 1); - } - // class map lookup if (isset($this->classMap[$class])) { return $this->classMap[$class]; @@ -325,6 +341,12 @@ class ClassLoader if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { return false; } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } $file = $this->findFileWithExtension($class, '.php'); @@ -333,6 +355,10 @@ class ClassLoader $file = $this->findFileWithExtension($class, '.hh'); } + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + if (false === $file) { // Remember that this class does not exist. $this->missingClasses[$class] = true; diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 7a4cc6eaa84..153b8056fb1 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -554,7 +554,6 @@ return array( 'OC\\Files\\Storage\\Wrapper\\Quota' => $baseDir . '/lib/private/Files/Storage/Wrapper/Quota.php', 'OC\\Files\\Storage\\Wrapper\\Wrapper' => $baseDir . '/lib/private/Files/Storage/Wrapper/Wrapper.php', 'OC\\Files\\Stream\\Close' => $baseDir . '/lib/private/Files/Stream/Close.php', - 'OC\\Files\\Stream\\Dir' => $baseDir . '/lib/private/Files/Stream/Dir.php', 'OC\\Files\\Stream\\Encryption' => $baseDir . '/lib/private/Files/Stream/Encryption.php', 'OC\\Files\\Stream\\Quota' => $baseDir . '/lib/private/Files/Stream/Quota.php', 'OC\\Files\\Stream\\StaticStream' => $baseDir . '/lib/private/Files/Stream/StaticStream.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 6a063f0d8c7..b251f25a761 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -584,7 +584,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Files\\Storage\\Wrapper\\Quota' => __DIR__ . '/../../..' . '/lib/private/Files/Storage/Wrapper/Quota.php', 'OC\\Files\\Storage\\Wrapper\\Wrapper' => __DIR__ . '/../../..' . '/lib/private/Files/Storage/Wrapper/Wrapper.php', 'OC\\Files\\Stream\\Close' => __DIR__ . '/../../..' . '/lib/private/Files/Stream/Close.php', - 'OC\\Files\\Stream\\Dir' => __DIR__ . '/../../..' . '/lib/private/Files/Stream/Dir.php', 'OC\\Files\\Stream\\Encryption' => __DIR__ . '/../../..' . '/lib/private/Files/Stream/Encryption.php', 'OC\\Files\\Stream\\Quota' => __DIR__ . '/../../..' . '/lib/private/Files/Stream/Quota.php', 'OC\\Files\\Stream\\StaticStream' => __DIR__ . '/../../..' . '/lib/private/Files/Stream/StaticStream.php', |