php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66760 error_log returns true when it fails when log file is read only
Submitted: 2014-02-24 04:17 UTC Modified: 2021-02-17 11:53 UTC
From: hj at BridgeportContractor dot com Assigned:
Status: Open Package: Unknown/Other Function
PHP Version: 5.4.25 OS: windows 7, x64 & Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: hj at BridgeportContractor dot com
New email:
PHP Version: OS:

 

 [2014-02-24 04:17 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-02-17 11:50 UTC] 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.
 [2021-02-17 11:53 UTC] cmb@php.net
> Anyhow, this should be documented.

<https://github.com/php/doc-en/commit/471f9f42cd9206eff6326b2cc6e159f8a0e096e2>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 25 10:01:32 2024 UTC