Skip to content
This repository was archived by the owner on May 16, 2018. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions library/Zend/Loader/PluginLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface
*/
protected static $_includeFileCache;

/**
* Class map cache file handler
* @var resource
*/
protected static $_includeFileCacheHandler;

/**
* Instance loaded plugin paths
*
Expand Down Expand Up @@ -438,6 +444,13 @@ public function load($name, $throwExceptions = true)
*/
public static function setIncludeFileCache($file)
{
if (!empty(self::$_includeFileCacheHandler)) {
flock(self::$_includeFileCacheHandler, LOCK_UN);
fclose(self::$_includeFileCacheHandler);
}

self::$_includeFileCacheHandler = null;

if (null === $file) {
self::$_includeFileCache = null;
return;
Expand Down Expand Up @@ -477,14 +490,17 @@ public static function getIncludeFileCache()
*/
protected static function _appendIncFile($incFile)
{
if (!file_exists(self::$_includeFileCache)) {
$file = '<?php';
} else {
$file = file_get_contents(self::$_includeFileCache);
if (!isset(self::$_includeFileCacheHandler)) {
self::$_includeFileCacheHandler = fopen(self::$_includeFileCache, 'ab');

if (!flock(self::$_includeFileCacheHandler, LOCK_EX | LOCK_NB, $wouldBlock) || $wouldBlock) {
self::$_includeFileCacheHandler = false;
}
}
if (!strstr($file, $incFile)) {
$file .= "\ninclude_once '$incFile';";
file_put_contents(self::$_includeFileCache, $file);

if (false !== self::$_includeFileCacheHandler) {
$line = "<?php include_once '$incFile'?>\n";
fwrite(self::$_includeFileCacheHandler, $line, strlen($line));
}
}
}