diff --git a/lib/Alchemy/Phrasea/Core.php b/lib/Alchemy/Phrasea/Core.php index d179df9e39..f81604266d 100644 --- a/lib/Alchemy/Phrasea/Core.php +++ b/lib/Alchemy/Phrasea/Core.php @@ -363,37 +363,12 @@ class Core extends \Pimple */ public static function initAutoloads($debug = false) { - require_once __DIR__ . '/../../vendor/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php'; - +// require_once __DIR__ . '/../../vendor/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php'; require_once __DIR__ . '/Loader/Autoloader.php'; - require_once __DIR__ . '/Loader/CacheAutoloader.php'; - -// require_once __DIR__ . '/../../vendor/Twig/lib/Twig/Autoloader.php'; -// require_once __DIR__ . '/../../vendor/Twig-extensions/lib/Twig/Extensions/Autoloader.php'; -// -// \Twig_Autoloader::register(); -// \Twig_Extensions_Autoloader::register(); - - -// if ($debug === false) -// { -// try -// { -// $loader = new Loader\CacheAutoloader('class_'); -// } -// catch (\Exception $e) -// { -// $loader = new Loader\Autoloader(); -// } -// } -// else -// { + $loader = new Loader\Autoloader(); - $loader->register(); - $loader = new \Symfony\Component\ClassLoader\UniversalClassLoader(); -// } - $loader->registerPrefixes(array('Twig_' => realpath(__DIR__ . '/../../vendor/Twig/lib'))); + $loader->registerPrefixes(array('Twig' => realpath(__DIR__ . '/../../vendor/Twig/lib'))); $loader->registerPrefixes(array('Twig_Extensions' => realpath(__DIR__ . '/../../vendor/Twig-extensions/lib'))); $loader->registerNamespaces(array( diff --git a/lib/Alchemy/Phrasea/Loader/ApcAutoloader.php b/lib/Alchemy/Phrasea/Loader/ApcAutoloader.php new file mode 100644 index 0000000000..0749885967 --- /dev/null +++ b/lib/Alchemy/Phrasea/Loader/ApcAutoloader.php @@ -0,0 +1,70 @@ +isAvailable()) + { + throw new \Exception("Apc cache is not enable"); + } + + $this->prefix = $prefix; + } + + /** + * Finds a file by class name while caching lookups to APC. + * + * @param string $class A class name to resolve to file + */ + public function findFile($class) + { + var_dump(__CLASS__ . " find : " . $class); + if (false === $file = apc_fetch($this->prefix . $class)) + { + apc_store($this->prefix . $class, $file = parent::findFile($class)); + } + + return $file; + } + + public function isAvailable() + { + return extension_loaded('apc'); + } + + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + +} \ No newline at end of file diff --git a/lib/Alchemy/Phrasea/Loader/Autoloader.php b/lib/Alchemy/Phrasea/Loader/Autoloader.php new file mode 100644 index 0000000000..df4967b024 --- /dev/null +++ b/lib/Alchemy/Phrasea/Loader/Autoloader.php @@ -0,0 +1,45 @@ +cacheStrategies as $className) + { + $method = new $className($prefix); + + if ($method instanceof LoaderStrategy && $method->isAvailable()) + { + $this->cache = $method; + break; + } + } + + if (null === $this->cache) + { + throw new Exception('No Cache available'); + } + } + + public function register($prepend = false) + { + $this->cache->register($prepend); + } + +} \ No newline at end of file diff --git a/lib/Alchemy/Phrasea/Loader/LoaderStrategy.php b/lib/Alchemy/Phrasea/Loader/LoaderStrategy.php new file mode 100644 index 0000000000..c649389ac7 --- /dev/null +++ b/lib/Alchemy/Phrasea/Loader/LoaderStrategy.php @@ -0,0 +1,24 @@ +isAvailable()) + { + throw new \Exception("Xcache cache is not enable"); + } + + $this->prefix = $prefix; + } + + /** + * Finds a file by class name while caching lookups to APC. + * + * @param string $class A class name to resolve to file + */ + public function findFile($class) + { + if (false === $file = xcache_get($this->prefix . $class)) + { + xcache_set($this->prefix . $class, $file = parent::findFile($class)); + } + + return $file; + } + + public function isAvailable() + { + return extension_loaded('xcache'); + } + + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + +} \ No newline at end of file diff --git a/lib/classes/patch/360.class.php b/lib/classes/patch/360.class.php index fabacc2be6..e52f2bc4cd 100644 --- a/lib/classes/patch/360.class.php +++ b/lib/classes/patch/360.class.php @@ -54,20 +54,6 @@ class patch_360 implements patchInterface function apply(base &$appbox) { -// $Core = bootstrap::getCore(); -// -// $sql = 'SELECT ssel_id, name FROM ssel'; -// -// $stmt = $appbox->get_connection()->prepare($sql); -// $stmt->execute(); -// $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); -// $stmt->closeCursor(); - - - $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(); - $stmt->closeCursor(); - $sql = 'INSERT INTO StoryWZ ( SELECT null as id, sbas_id, rid as record_id, usr_id, date as created