diff --git a/common/log/class.SingleFileAppender.php b/common/log/class.SingleFileAppender.php index 8bad1d9ec..7c60bf617 100644 --- a/common/log/class.SingleFileAppender.php +++ b/common/log/class.SingleFileAppender.php @@ -136,11 +136,17 @@ protected function initFile() { if ($this->maxFileSize > 0 && file_exists($this->filename) && filesize($this->filename) >= $this->maxFileSize) { // need to reduce the file size - $file = file($this->filename); - $file = array_splice($file, ceil(count($file) * $this->reduceRatio)); + $reduceLen= ($this->maxFileSize< (int)ini_get('memory_limit')*1024?$this->maxFileSize:(int)ini_get('memory_limit')*1024)*$this->reduceRatio; + $size = filesize($this->filename)-$reduceLen; + $log =file_get_contents($this->filename, false, null, $size, $reduceLen ); + + $log= explode(PHP_EOL, $log); + //delete first element (can be broken) + array_shift($log); + $this->filehandle = @fopen($this->filename, 'w'); - foreach ($file as $line) { - @fwrite($this->filehandle, $line); + foreach ($log as $line) { + @fwrite($this->filehandle, $line.PHP_EOL); } } else { $this->filehandle = @fopen($this->filename, 'a'); diff --git a/manifest.php b/manifest.php index 813974414..dcf44dcf8 100755 --- a/manifest.php +++ b/manifest.php @@ -31,7 +31,7 @@ 'label' => 'Generis Core', 'description' => 'Core extension, provide the low level framework and an API to manage ontologies', 'license' => 'GPL-2.0', - 'version' => '8.2.1', + 'version' => '8.2.2', 'author' => 'Open Assessment Technologies, CRP Henri Tudor', 'requires' => array(), 'models' => array( diff --git a/scripts/update/Updater.php b/scripts/update/Updater.php index 76f68b8e9..23253a09e 100644 --- a/scripts/update/Updater.php +++ b/scripts/update/Updater.php @@ -361,6 +361,6 @@ public function update($initialVersion) $this->setVersion('8.0.0'); } - $this->skip('8.0.0', '8.2.1'); + $this->skip('8.0.0', '8.2.2'); } }