@@ -43,6 +43,12 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface
4343 */
4444 protected static $ _includeFileCache ;
4545
46+ /**
47+ * Class map cache file handler
48+ * @var resource
49+ */
50+ protected static $ _includeFileCacheHandler ;
51+
4652 /**
4753 * Instance loaded plugin paths
4854 *
@@ -438,6 +444,13 @@ public function load($name, $throwExceptions = true)
438444 */
439445 public static function setIncludeFileCache ($ file )
440446 {
447+ if (!empty (self ::$ _includeFileCacheHandler )) {
448+ flock (self ::$ _includeFileCacheHandler , LOCK_UN );
449+ fclose (self ::$ _includeFileCacheHandler );
450+ }
451+
452+ self ::$ _includeFileCacheHandler = null ;
453+
441454 if (null === $ file ) {
442455 self ::$ _includeFileCache = null ;
443456 return ;
@@ -477,18 +490,17 @@ public static function getIncludeFileCache()
477490 */
478491 protected static function _appendIncFile ($ incFile )
479492 {
480- static $ h = null ;
493+ if (null === self ::$ _includeFileCacheHandler ) {
494+ self ::$ _includeFileCacheHandler = fopen (self ::$ _includeFileCache , 'ab ' );
481495
482- if (null === $ h ) {
483- $ h = fopen (self ::$ _includeFileCache , 'ab ' );
484- if (!flock ($ h , LOCK_EX | LOCK_NB , $ wb ) || $ wb ) {
485- $ h = false ;
496+ if (!flock (self ::$ _includeFileCacheHandler , LOCK_EX | LOCK_NB , $ wouldBlock ) || $ wouldBlock ) {
497+ self ::$ _includeFileCacheHandler = false ;
486498 }
487499 }
488500
489- if (false !== $ h ) {
501+ if (false !== self :: $ _includeFileCacheHandler ) {
490502 $ line = "<?php include_once ' $ incFile'?> \n" ;
491- fwrite ($ h , $ line , strlen ($ line ));
503+ fwrite (self :: $ _includeFileCacheHandler , $ line , strlen ($ line ));
492504 }
493505 }
494506}
0 commit comments