From 838c9a96f645aac24daa31285efa1051535c4219 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 13 Sep 2013 14:05:13 +0300 Subject: Drop the unused parameter from log_message() / CI_Log::write_log() --- system/core/Log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Log.php') diff --git a/system/core/Log.php b/system/core/Log.php index e4d72b544..20bc55986 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -143,7 +143,7 @@ class CI_Log { * @param bool whether the error is a native PHP error * @return bool */ - public function write_log($level, $msg, $php_error = FALSE) + public function write_log($level, $msg) { if ($this->_enabled === FALSE) { -- cgit v1.2.3-24-g4f1b From e890ecf4403fe6be6dea9809ba51a3a8f66b0b2e Mon Sep 17 00:00:00 2001 From: vkeranov Date: Sat, 14 Sep 2013 21:38:05 +0300 Subject: No need of this anymore --- system/core/Log.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'system/core/Log.php') diff --git a/system/core/Log.php b/system/core/Log.php index 20bc55986..0390aba0b 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -140,7 +140,6 @@ class CI_Log { * * @param string the error level: 'error', 'debug' or 'info' * @param string the error message - * @param bool whether the error is a native PHP error * @return bool */ public function write_log($level, $msg) @@ -194,4 +193,4 @@ class CI_Log { } /* End of file Log.php */ -/* Location: ./system/core/Log.php */ \ No newline at end of file +/* Location: ./system/core/Log.php */ -- cgit v1.2.3-24-g4f1b From 13c818ee2f7424050cf363dceac7512bf9f9f943 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 14 Sep 2013 21:44:36 +0300 Subject: [ci skip] Remove empty lines --- system/core/Log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Log.php') diff --git a/system/core/Log.php b/system/core/Log.php index 0390aba0b..b2327b8f0 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -193,4 +193,4 @@ class CI_Log { } /* End of file Log.php */ -/* Location: ./system/core/Log.php */ +/* Location: ./system/core/Log.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 3d215207ceff44193e3c1888b868fc3f691718c0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 15 Jan 2014 11:08:47 +0200 Subject: Fix incorrect checks for the fwrite() return value ! fwrite() could trigger false-positives as it is possible for it to return 0 instead of boolean FALSE. (issue #2822) Also removed an unnecessary log level check that caused an extra space to be inserted for the INFO level. (proposed in PR #2821) --- system/core/Log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Log.php') diff --git a/system/core/Log.php b/system/core/Log.php index b2327b8f0..ff3c63568 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -175,7 +175,7 @@ class CI_Log { return FALSE; } - $message .= $level.' '.($level === 'INFO' ? ' -' : '-').' '.date($this->_date_fmt).' --> '.$msg."\n"; + $message .= $level.' - '.date($this->_date_fmt).' --> '.$msg."\n"; flock($fp, LOCK_EX); fwrite($fp, $message); -- cgit v1.2.3-24-g4f1b From d8b1ad31cf7ee205ddf3cf396b1d1bfa45af49fa Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 15 Jan 2014 17:42:52 +0200 Subject: Fix #2822: Incorrect usage of fwrite() We only used to check (and not always) if the return value of fwrite() is boolean FALSE, while it is possible that the otherwise returned bytecount is less than the length of data that we're trying to write. This allowed incomplete writes over network streams and possibly a few other edge cases. --- system/core/Log.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'system/core/Log.php') diff --git a/system/core/Log.php b/system/core/Log.php index ff3c63568..63fef2088 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -178,7 +178,15 @@ class CI_Log { $message .= $level.' - '.date($this->_date_fmt).' --> '.$msg."\n"; flock($fp, LOCK_EX); - fwrite($fp, $message); + + for ($written = 0, $length = strlen($message); $written < $length; $written += $result) + { + if (($result = fwrite($fp, substr($message, $written))) === FALSE) + { + break; + } + } + flock($fp, LOCK_UN); fclose($fp); @@ -187,7 +195,7 @@ class CI_Log { @chmod($filepath, FILE_WRITE_MODE); } - return TRUE; + return is_int($result); } } -- cgit v1.2.3-24-g4f1b