Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

hotfix cache #218

Closed
wants to merge 3 commits into from

4 participants

@jakoch

a) replaced silence operator by is_file() check.
If there is a lock or permission problem while unlinking a file, the error should pop up.
b) replaced little typo in constant name (availiable => available)

@doctrinebot
Collaborator

Hello,

thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link:

http://doctrine-project.org/jira/browse/DCOM-137

@schmittjoh schmittjoh commented on the diff
lib/Doctrine/Common/Cache/Cache.php
@@ -38,8 +38,8 @@
const STATS_HITS = 'hits';
const STATS_MISSES = 'misses';
const STATS_UPTIME = 'uptime';
- const STATS_MEMORY_USAGE = 'memory_usage';
- const STATS_MEMORY_AVAILIABLE = 'memory_available';
+ const STATS_MEMORY_USAGE = 'memory_usage';
+ const STATS_MEMORY_AVAILABLE = 'memory_available';
@schmittjoh Collaborator

Can you keep the old constant as well for BC?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@beberlei
Owner

Can you make two PRs out of this? It fixes two completly different things.

@jakoch

Sure - splitted the PR into two new PRs.
#219
#220
Closing this one.

@jakoch jakoch closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  lib/Doctrine/Common/Cache/ApcCache.php
@@ -87,7 +87,7 @@ protected function doGetStats()
Cache::STATS_MISSES => $info['num_misses'],
Cache::STATS_UPTIME => $info['start_time'],
Cache::STATS_MEMORY_USAGE => $info['mem_size'],
- Cache::STATS_MEMORY_AVAILIABLE => $sma['avail_mem'],
+ Cache::STATS_MEMORY_AVAILABLE => $sma['avail_mem'],
);
}
}
View
4 lib/Doctrine/Common/Cache/Cache.php
@@ -38,8 +38,8 @@
const STATS_HITS = 'hits';
const STATS_MISSES = 'misses';
const STATS_UPTIME = 'uptime';
- const STATS_MEMORY_USAGE = 'memory_usage';
- const STATS_MEMORY_AVAILIABLE = 'memory_available';
+ const STATS_MEMORY_USAGE = 'memory_usage';
+ const STATS_MEMORY_AVAILABLE = 'memory_available';
@schmittjoh Collaborator

Can you keep the old constant as well for BC?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
/**
* Fetches an entry from the cache.
View
16 lib/Doctrine/Common/Cache/FileCache.php
@@ -68,7 +68,7 @@ public function __construct($directory, $extension = null)
/**
* Gets the cache directory.
- *
+ *
* @return string
*/
public function getDirectory()
@@ -78,7 +78,7 @@ public function getDirectory()
/**
* Gets the cache file extension.
- *
+ *
* @return string
*/
public function getExtension()
@@ -102,7 +102,13 @@ protected function getFilename($id)
*/
protected function doDelete($id)
{
- return @unlink($this->getFilename($id));
+ $file = $this->getFilename($id);
+
+ if (is_file($file)) {
+ return unlink($file);
+ }
+
+ return false;
}
/**
@@ -116,7 +122,9 @@ protected function doFlush()
$iterator = new \RegexIterator($iterator, $pattern);
foreach ($iterator as $name => $file) {
- @unlink($name);
+ if(is_file($name)) {
+ unlink($name);
+ }
}
return true;
View
2  lib/Doctrine/Common/Cache/MemcacheCache.php
@@ -115,7 +115,7 @@ protected function doGetStats()
Cache::STATS_MISSES => $stats['get_misses'],
Cache::STATS_UPTIME => $stats['uptime'],
Cache::STATS_MEMORY_USAGE => $stats['bytes'],
- Cache::STATS_MEMORY_AVAILIABLE => $stats['limit_maxbytes'],
+ Cache::STATS_MEMORY_AVAILABLE => $stats['limit_maxbytes'],
);
}
}
View
2  lib/Doctrine/Common/Cache/MemcachedCache.php
@@ -118,7 +118,7 @@ protected function doGetStats()
Cache::STATS_MISSES => $stats['get_misses'],
Cache::STATS_UPTIME => $stats['uptime'],
Cache::STATS_MEMORY_USAGE => $stats['bytes'],
- Cache::STATS_MEMORY_AVAILIABLE => $stats['limit_maxbytes'],
+ Cache::STATS_MEMORY_AVAILABLE => $stats['limit_maxbytes'],
);
}
}
View
4 lib/Doctrine/Common/Cache/RedisCache.php
@@ -81,7 +81,7 @@ protected function doSave($id, $data, $lifeTime = 0)
{
$result = $this->redis->set($id, $data);
if ($lifeTime > 0) {
- $this->redis->expire($id, $lifeTime);
+ $this->redis->expire($id, $lifeTime);
}
return $result;
}
@@ -113,7 +113,7 @@ protected function doGetStats()
Cache::STATS_MISSES => false,
Cache::STATS_UPTIME => $info['uptime_in_seconds'],
Cache::STATS_MEMORY_USAGE => $info['used_memory'],
- Cache::STATS_MEMORY_AVAILIABLE => false
+ Cache::STATS_MEMORY_AVAILABLE => false
);
}
}
View
2  lib/Doctrine/Common/Cache/WinCacheCache.php
@@ -87,7 +87,7 @@ protected function doGetStats()
Cache::STATS_MISSES => $info['total_miss_count'],
Cache::STATS_UPTIME => $info['total_cache_uptime'],
Cache::STATS_MEMORY_USAGE => $meminfo['memory_total'],
- Cache::STATS_MEMORY_AVAILIABLE => $meminfo['memory_free'],
+ Cache::STATS_MEMORY_AVAILABLE => $meminfo['memory_free'],
);
}
}
View
2  lib/Doctrine/Common/Cache/XcacheCache.php
@@ -104,7 +104,7 @@ protected function doGetStats()
Cache::STATS_MISSES => $info['misses'],
Cache::STATS_UPTIME => null,
Cache::STATS_MEMORY_USAGE => $info['size'],
- Cache::STATS_MEMORY_AVAILIABLE => $info['avail'],
+ Cache::STATS_MEMORY_AVAILABLE => $info['avail'],
);
}
}
View
2  tests/Doctrine/Tests/Common/Cache/CacheTest.php
@@ -81,7 +81,7 @@ public function testGetStats()
$this->assertArrayHasKey(Cache::STATS_MISSES, $stats);
$this->assertArrayHasKey(Cache::STATS_UPTIME, $stats);
$this->assertArrayHasKey(Cache::STATS_MEMORY_USAGE, $stats);
- $this->assertArrayHasKey(Cache::STATS_MEMORY_AVAILIABLE, $stats);
+ $this->assertArrayHasKey(Cache::STATS_MEMORY_AVAILABLE, $stats);
}
/**
Something went wrong with that request. Please try again.