Details
-
Bug
-
Resolution: Obsolete
-
Medium
-
None
-
4.0.7, 4.1.4, 4.2.0
-
None
Description
The fact is that the filesize() call used to determine if logfile is too big and needs rotation is cached by php.
Simple test: put this in a view or cronjob
for ($i = 0; $i < 1024; $i++) for ($j = 0; $j < 1024; $j++) eZDebug::writeDebug( "$i $j" );
and watch your log grow over 3MB...
The fix involves clearing the stat cache after logging, but to avoid impacting globally the cache stat it should imho be done only on php > 5.3.0:
$fileExisted = @file_exists( $fileName ); if ( $fileExisted and filesize( $fileName ) > eZDebug::maxLogSize() ) { if ( eZDebug::rotateLog( $fileName ) ) $fileExisted = false; } $logFile = @fopen( $fileName, "a" ); if ( $logFile ) { $time = strftime( "%b %d %Y %H:%M:%S", strtotime( "now" ) ); $ip = eZSys::serverVariable( 'REMOTE_ADDR', true ); if ( !$ip ) $ip = eZSys::serverVariable( 'HOSTNAME', true ); $notice = "[ " . $time . " ] [" . $ip . "] " . $string . "\n"; @fwrite( $logFile, $notice ); @fclose( $logFile ); // new line clearstatcache( false, $fileName ); if ( !$fileExisted ) { $ini = eZINI::instance(); $permissions = octdec( $ini->variable( 'FileSettings', 'LogFilePermissions' ) ); @chmod( $fileName, $permissions ); } @umask( $oldumask ); }
Attachments
Issue Links
- relates to
-
EZP-19836 log size declared in config.php fails to apply
- Closed