Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-15971

log rotation does not happen while one single eZ php script is executing

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Obsolete
    • Icon: Medium Medium
    • None
    • 4.0.7, 4.1.4, 4.2.0
    • Misc
    • 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

        Activity

          People

            unknown unknown
            72f8acac-185f-4a54-9470-a7473f50daab@accounts.ibexa.co Gaetano Giunta
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: