From 2abd623b3e23c27b9084fc6fdfca0dffed265637 Mon Sep 17 00:00:00 2001 From: Ihar Aleksiaichuk Date: Tue, 12 Feb 2019 12:42:57 +0300 Subject: [PATCH 1/2] fixed: memory limit reading file --- common/log/class.SingleFileAppender.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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'); From a034c02e0a6bd9aa355e80c94c5c18dd322bc21f Mon Sep 17 00:00:00 2001 From: Ihar Aleksiaichuk Date: Tue, 12 Feb 2019 13:11:11 +0300 Subject: [PATCH 2/2] changed version --- manifest.php | 2 +- scripts/update/Updater.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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'); } }