You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4php-dev@logging.apache.org by "Ivan Habunek (JIRA)" <ji...@apache.org> on 2012/09/01 09:15:08 UTC
[jira] [Commented] (LOG4PHP-185) Don't clear the entire stat cache
on an append
[ https://issues.apache.org/jira/browse/LOG4PHP-185?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13446627#comment-13446627 ]
Ivan Habunek commented on LOG4PHP-185:
--------------------------------------
We aim to remain compatible with 5.2, until the next major version, so a conditional would be needed there.
Maybe something along these lines:
Index: LoggerAppenderRollingFile.php
===================================================================
--- LoggerAppenderRollingFile.php (revision 1374786)
+++ LoggerAppenderRollingFile.php (working copy)
@@ -79,6 +79,15 @@
*/
protected $compress = false;
+ private $clearConditional = false;
+
+ public function __construct($name = '') {
+ parent::__construct($name);
+ if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
+ $this->clearConditional = true;
+ }
+ }
+
/**
* Get the maximum size that the output file is allowed to reach
* before being rolled over to backup files.
@@ -195,7 +204,11 @@
}
// Stats cache must be cleared, otherwise filesize() returns cached results
- clearstatcache();
+ if ($this->clearConditional) {
+ clearstatcache(true, $this->file);
+ } else {
+ clearstatcache();
+ }
// Rollover if needed
if (filesize($this->file) > $this->maxFileSize) {
> Don't clear the entire stat cache on an append
> ----------------------------------------------
>
> Key: LOG4PHP-185
> URL: https://issues.apache.org/jira/browse/LOG4PHP-185
> Project: Log4php
> Issue Type: Improvement
> Reporter: Rasmus Lerdorf
> Fix For: 2.2.1
>
>
> As of PHP 5.3.0 you can selectively clear individual entries from the stat cache. So, I suggest this change:
> Index: src/main/php/appenders/LoggerAppenderRollingFile.php
> ===================================================================
> --- src/main/php/appenders/LoggerAppenderRollingFile.php (revision 1379664)
> +++ src/main/php/appenders/LoggerAppenderRollingFile.php (working copy)
> @@ -195,7 +195,7 @@
> }
>
> // Stats cache must be cleared, otherwise filesize() returns cached results
> - clearstatcache();
> + clearstatcache(true, $this->file);
>
> // Rollover if needed
> if (filesize($this->file) > $this->maxFileSize) {
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira