Bug #66760 [Opn]: error_log returns true when it fails when log file is read only
| From: | cmb@php.net | Date: | Wed, 17 Feb 2021 11:53:22 +0000 |
| Subject: | Bug #66760 [Opn]: error_log returns true when it fails when log file is read only | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-232222@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66760&edit=1
ID: 66760
Updated by: cmb@php.net
Reported by: hj at BridgeportContractor dot com
Summary: error_log returns true when it fails when log file
is read only
Status: Open
Type: Bug
Package: Unknown/Other Function
Operating System: windows 7, x64 & Linux
PHP Version: 5.4.25
Block user comment: N
Private report: N
New Comment:
> Anyhow, this should be documented.
<https://github.com/php/doc-en/commit/471f9f42cd9206eff6326b2cc6e159f8a0e096e2>
Previous Comments:
------------------------------------------------------------------------
[2021-02-17 11:50:07] cmb@php.net
Oh, indeed, that happens whenever $message_type===0. The basic
problem is that php_log_err_with_severity() is a void function,
and as such cannot report success/failure. Changing this would
constitute an ABI break, and as such cannot be done for any stable
PHP version.
Anyhow, this should be documented.
------------------------------------------------------------------------
[2014-02-24 04:17:08] hj at BridgeportContractor dot com
Description:
------------
If the log file is read only on either Win or Linux error_log() still returns true as a success
flag, even thought the log message was never written. It should return false I think if the log is
not written.
?? Is this a cgi thing? Don't think so, because my win-7 php is Apache mod-php, and the
linux-php is fastcgi.
...A meta bug: an error, in the error_log :-)
Thanks.
Test script:
---------------
<?php
// I'm not sure you need all this to demonstrate the problem, but this is what // I have set
that might possibly relate to this issue:
error_reporting(E_ALL);
ini_set('display_errors' ,'On');
ini_set('log_errors' ,'On');
ini_set('error_log' ,'/php_errors.log');
ini_set('display_startup_errors' ,'On');
ini_set('ignore_repeated_errors' ,'Off');
ini_set('ignore_repeated_source' ,'off');
ini_set('log_errors_max_len' ,1024);
var_dump(error_log('test')); // When php_errors.log is read only in windows,
// or 444 in Linux this returns true but
// should return false. What I want is if the
// log fails that I can report it elsewhere.
Expected result:
----------------
false
Actual result:
--------------
true
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66760&edit=1