Skip to content
This repository was archived by the owner on May 16, 2018. It is now read-only.

Commit 8d2a2af

Browse files
Code cleanup
1 parent 1688f3d commit 8d2a2af

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

library/Zend/Loader/PluginLoader.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)