ID:               30393
 Updated by:       php-bugs@lists.php.net
 Reported By:      richard dot quadling at bandvulc dot co dot uk
-Status:           Feedback
+Status:           No Feedback
 Bug Type:         Scripting Engine problem
 Operating System: Windows XP SP2
 PHP Version:      5.0.2
 New Comment:

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".


Previous Comments:
------------------------------------------------------------------------

[2005-03-07 22:04:26] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip



------------------------------------------------------------------------

[2004-10-11 10:38:27] richard dot quadling at bandvulc dot co dot uk

I may have got the CLI / ISAPI bits back to front half way through
this.

Sorry.

------------------------------------------------------------------------

[2004-10-11 10:13:51] richard dot quadling at bandvulc dot co dot uk

Description:
------------
I use both CLI and ISAPI PHP code.

I have PHP.INI set to log errors to "PHP Errors.log".

If I have an error in a CLI program, the error that is logged ends with
CR/LF.

If I have an error in a ISAPI program (i.e. launched by a web server),
I get the error with CR/CR/LF. One too many CR.

An example from my error log file (hoping that this gets through
cleanly)...

[08-Oct-2004 15:00:03] PHP Notice:  Undefined offset:  1 in C:\McAfee
AntiVirus Updates\AVUpdate.php on line 90[cr/lf]
[08-Oct-2004 15:00:03] PHP Notice:  Undefined offset:  2 in C:\McAfee
AntiVirus Updates\AVUpdate.php on line 90[cr/lf]
[08-Oct-2004 15:18:54] PHP Notice:  Undefined variable:  _SESSION in
C:\WebSites\PHP\Includes\class_Form_Maint.inc on line 332[cr/cr/lf]

[08-Oct-2004 15:18:54] PHP Notice:  Undefined variable:
sRequireFormAction in C:\WebSites\PHP\Includes\class_Form_Maint.inc on
line 332[cr/cr/lf]

[08-Oct-2004 15:18:54] PHP Notice:  Undefined variable:  _SESSION in
C:\WebSites\PHP\Includes\class_Form_Maint.inc on line 332[cr/cr/lf]



I'm not using the CGI version.

Having examined the source, I can see why this happens the extra CR
occurs.

In Windows, opening a file using C's fopen, will open the file in text
mode unless 'b' as a mode.

So, the constant PHP_EOL is set to "\r\n" (main\php.h line 58).

The function php_log_err (main\main.c line 344) only uses append mode -
"a" - to open the file. Which will be in text mode and "\r\n" will
become "\r\r\n", as "\n" => "\r\n" in a text file.

But, why this is not true for the CLI version ...

Now. The PHP_EOL was added by 5.0.2 (NEWS line 10).

Examining main\php.h (Lines 49 to 68) it LOOKS like there is a way
through to setting PHP_EOL to \n (which is what the CLI version is
outputting.

I am not sure, but is the constant PHP_WIN32 set for ALL windows forms
of PHP (ISAPI, CGI, CLI)? If not, then this may be a cause. I can see
no other way that PHP_EOL could NOT be "\r\n" (which is wrong for a
text file, but ...).

Solution? I think opening the error file in binary mode ("ab") will
mean you do not need to change the PHP_EOL.

As a final request, is there any one who can help me get PHP to
compile? I don't have newsgroup access here.

Regards,

Richard Quadling.

Reproduce code:
---------------
Set PHP ...

error_log = C:\WebSites\PHP\PHP Errors.log      

and then any PHP code that will generate an error.

<?php

$var = 1 / 0; // Cannot divide by zero.

?>

Run this in both CLI and ISAPI mode.

I ran the program 4 times, first in ISAPI mode (via a webpage) and then
in CLI mode.


Expected result:
----------------
[11-Oct-2004 09:09:22] PHP Warning:  Division by zero in Unknown on
line 0[cr/lf]
[11-Oct-2004 09:09:36] PHP Warning:  Division by zero in Unknown on
line 0[cr/lf]
[11-Oct-2004 09:09:37] PHP Warning:  Division by zero in Unknown on
line 0[cr/lf]
[11-Oct-2004 09:09:37] PHP Warning:  Division by zero in Unknown on
line 0[cr/lf]
[11-Oct-2004 09:09:56] PHP Warning:  Division by zero in Unknown on
line 0[cr/lf]
[11-Oct-2004 09:09:57] PHP Warning:  Division by zero in Unknown on
line 0[cr/lf]
[11-Oct-2004 09:09:57] PHP Warning:  Division by zero in Unknown on
line 0[cr/lf]
[11-Oct-2004 09:09:57] PHP Warning:  Division by zero in Unknown on
line 0[cr/lf]

Actual result:
--------------
[11-Oct-2004 09:09:22] PHP Warning:  Division by zero in Unknown on
line 0[cr/cr/lf]
[11-Oct-2004 09:09:36] PHP Warning:  Division by zero in Unknown on
line 0[cr/cr/lf]
[11-Oct-2004 09:09:37] PHP Warning:  Division by zero in Unknown on
line 0[cr/cr/lf]
[11-Oct-2004 09:09:37] PHP Warning:  Division by zero in Unknown on
line 0[cr/cr/lf]
[11-Oct-2004 09:09:56] PHP Warning:  Division by zero in Unknown on
line 0[cr/lf]
[11-Oct-2004 09:09:57] PHP Warning:  Division by zero in Unknown on
line 0[cr/lf]
[11-Oct-2004 09:09:57] PHP Warning:  Division by zero in Unknown on
line 0[cr/lf]
[11-Oct-2004 09:09:57] PHP Warning:  Division by zero in Unknown on
line 0[cr/lf]


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=30393&edit=1

Reply via email to