Commit 6ff84eeb authored by Karl Denninger's avatar Karl Denninger

ZP-1284 Composer update. Released under the Affero GNU General Public License (AGPL) version 3.

parent fd1c4a66
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
// autoload.php @generated by Composer // autoload.php @generated by Composer
require_once __DIR__ . '/composer' . '/autoload_real.php'; require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitd6749fc2fb9944bbe86b2b7d79a7852f::getLoader(); return ComposerAutoloaderInitd6749fc2fb9944bbe86b2b7d79a7852f::getLoader();
...@@ -53,8 +53,9 @@ class ClassLoader ...@@ -53,8 +53,9 @@ class ClassLoader
private $useIncludePath = false; private $useIncludePath = false;
private $classMap = array(); private $classMap = array();
private $classMapAuthoritative = false; private $classMapAuthoritative = false;
private $missingClasses = array();
private $apcuPrefix;
public function getPrefixes() public function getPrefixes()
{ {
...@@ -271,6 +272,26 @@ class ClassLoader ...@@ -271,6 +272,26 @@ class ClassLoader
return $this->classMapAuthoritative; return $this->classMapAuthoritative;
} }
/**
* 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. * Registers this instance as an autoloader.
* *
...@@ -313,29 +334,34 @@ class ClassLoader ...@@ -313,29 +334,34 @@ class ClassLoader
*/ */
public function findFile($class) 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 // class map lookup
if (isset($this->classMap[$class])) { if (isset($this->classMap[$class])) {
return $this->classMap[$class]; return $this->classMap[$class];
} }
if ($this->classMapAuthoritative) { if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false; return false;
} }
if (null !== $this->apcuPrefix) {
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
if ($hit) {
return $file;
}
}
$file = $this->findFileWithExtension($class, '.php'); $file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM // Search for Hack files if we are running on HHVM
if ($file === null && defined('HHVM_VERSION')) { if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh'); $file = $this->findFileWithExtension($class, '.hh');
} }
if ($file === null) { if (null !== $this->apcuPrefix) {
apcu_add($this->apcuPrefix.$class, $file);
}
if (false === $file) {
// Remember that this class does not exist. // Remember that this class does not exist.
return $this->classMap[$class] = false; $this->missingClasses[$class] = true;
} }
return $file; return $file;
...@@ -348,9 +374,13 @@ class ClassLoader ...@@ -348,9 +374,13 @@ class ClassLoader
$first = $class[0]; $first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) { if (isset($this->prefixLengthsPsr4[$first])) {
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { $subPath = $class;
if (0 === strpos($class, $prefix)) { while (false !== $lastPos = strrpos($subPath, '\\')) {
foreach ($this->prefixDirsPsr4[$prefix] as $dir) { $subPath = substr($subPath, 0, $lastPos);
$search = $subPath.'\\';
if (isset($this->prefixDirsPsr4[$search])) {
foreach ($this->prefixDirsPsr4[$search] as $dir) {
$length = $this->prefixLengthsPsr4[$first][$search];
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
return $file; return $file;
} }
...@@ -399,6 +429,8 @@ class ClassLoader ...@@ -399,6 +429,8 @@ class ClassLoader
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file; return $file;
} }
return false;
} }
} }
......
Copyright (c) 2016 Nils Adermann, Jordi Boggiano Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
......
...@@ -29,6 +29,7 @@ return array( ...@@ -29,6 +29,7 @@ return array(
'BackendLDAP' => $baseDir . '/backend/ldap/ldap.php', 'BackendLDAP' => $baseDir . '/backend/ldap/ldap.php',
'BackendMaildir' => $baseDir . '/backend/maildir/maildir.php', 'BackendMaildir' => $baseDir . '/backend/maildir/maildir.php',
'BackendSearchLDAP' => $baseDir . '/backend/searchldap/searchldap.php', 'BackendSearchLDAP' => $baseDir . '/backend/searchldap/searchldap.php',
'BackendStickyNote' => $baseDir . '/backend/stickynote/stickynote.php',
'BackendVCardDir' => $baseDir . '/backend/vcarddir/vcarddir.php', 'BackendVCardDir' => $baseDir . '/backend/vcarddir/vcarddir.php',
'BackendZarafa' => $baseDir . '/backend/kopano/kopano.php', 'BackendZarafa' => $baseDir . '/backend/kopano/kopano.php',
'BaseException' => $baseDir . '/backend/kopano/mapi/class.baseexception.php', 'BaseException' => $baseDir . '/backend/kopano/mapi/class.baseexception.php',
......
...@@ -23,7 +23,7 @@ class ComposerAutoloaderInitd6749fc2fb9944bbe86b2b7d79a7852f ...@@ -23,7 +23,7 @@ class ComposerAutoloaderInitd6749fc2fb9944bbe86b2b7d79a7852f
self::$loader = $loader = new \Composer\Autoload\ClassLoader(); self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitd6749fc2fb9944bbe86b2b7d79a7852f', 'loadClassLoader')); spl_autoload_unregister(array('ComposerAutoloaderInitd6749fc2fb9944bbe86b2b7d79a7852f', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION'); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) { if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php'; require_once __DIR__ . '/autoload_static.php';
......
...@@ -36,6 +36,7 @@ class ComposerStaticInitd6749fc2fb9944bbe86b2b7d79a7852f ...@@ -36,6 +36,7 @@ class ComposerStaticInitd6749fc2fb9944bbe86b2b7d79a7852f
'BackendLDAP' => __DIR__ . '/../..' . '/backend/ldap/ldap.php', 'BackendLDAP' => __DIR__ . '/../..' . '/backend/ldap/ldap.php',
'BackendMaildir' => __DIR__ . '/../..' . '/backend/maildir/maildir.php', 'BackendMaildir' => __DIR__ . '/../..' . '/backend/maildir/maildir.php',
'BackendSearchLDAP' => __DIR__ . '/../..' . '/backend/searchldap/searchldap.php', 'BackendSearchLDAP' => __DIR__ . '/../..' . '/backend/searchldap/searchldap.php',
'BackendStickyNote' => __DIR__ . '/../..' . '/backend/stickynote/stickynote.php',
'BackendVCardDir' => __DIR__ . '/../..' . '/backend/vcarddir/vcarddir.php', 'BackendVCardDir' => __DIR__ . '/../..' . '/backend/vcarddir/vcarddir.php',
'BackendZarafa' => __DIR__ . '/../..' . '/backend/kopano/kopano.php', 'BackendZarafa' => __DIR__ . '/../..' . '/backend/kopano/kopano.php',
'BaseException' => __DIR__ . '/../..' . '/backend/kopano/mapi/class.baseexception.php', 'BaseException' => __DIR__ . '/../..' . '/backend/kopano/mapi/class.baseexception.php',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment