Edit report at https://bugs.php.net/bug.php?id=63106&edit=1
ID: 63106
Comment by: valentiny510 at yahoo dot es
Reported by: valentiny510 at yahoo dot es
Summary: get_headers( ) loops on localhost
Status: Not a bug
Type: Bug
Package: Streams related
Operating System: Windows XP
PHP Version: 5.4.7
Block user comment: N
Private report: N
New Comment:
Is not "predictable" ? What about some static variable or something like this ?
(pseudofunction)
function get_headers( url )
{
server_from_where_script_is_called = $_SERVER['host'];
if ( url == same_server )
error('Cannot get the headers from the same domain bla bla bla');
else
// do normal stuff ...
}
What about traspassing the script time limit ?
Previous Comments:
------------------------------------------------------------------------
[2012-09-18 10:30:14] [email protected]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php
no, because the recursive is not predictable for PHP,
get_headers will send a request to the target url, and get the response,
in your test, the target is the script self, then it call get_headers again and
agian.
------------------------------------------------------------------------
[2012-09-18 09:00:26] valentiny510 at yahoo dot es
I would espect at least something like var_export( $GLOBALS );
"Nesting level too deep - recursive dependency?"
------------------------------------------------------------------------
[2012-09-18 08:28:14] [email protected]
I don't understand what's bug do you mean?
recursive calling getheaders obviously will result a infinite loop.
------------------------------------------------------------------------
[2012-09-18 07:29:22] valentiny510 at yahoo dot es
Description:
------------
First I want to say I have an offer of 2x1 bugs. I will start with a bit of
history.. (for some reason) I have a test server added to my
system32/drivers/etc/hosts. Ex: 127.0.0.1 testserver.com
and I thought the problem can be the name of something like that, and deletind
the line doesn't solve the problem, and then I realized that the problem is the
function inself with the localhost.
Is almost understandable becouse it try to get the self headers over and over
again. Almost like: function get($headers){return get($headers);}
The subsequent problem is that is bypassing the time limit of the script, 30
seconds (or whatever time limit is) and the script when reach the limit, the
limit is restarted and run again for few minutes 'till the browser stop it.
The error.log will have thousands of line with the error limit..
The documentation doesn't say nothing about localhost.
Speaking of error log, here come the second bug. NOTE: only happens with the
bug above ! That why I put together. Ok.. lets see..
For production (like almost everybody, i guess) I use:
ini_set('log_errors', false);
ini_set('display_errors', false);
Ok.. When I try to see the error returned by the above bug with "display_error
true", nothing is showed, and ONLY when "log_errors are true" it show me the
error "Time limit 30 seconds etc...", also it show me the error with
"display_errors false" too ! Something strange there..
Maybe is becouse the script running foreaver, when the browser it stop it, the
php does have nothing "prepared" to show.. and must get something from the
error.log to display something to the browser
To finish, maybe the second is the subsequent of the first bug (almost sure it
is), so dont give to mush importance to that, and fix just the first one.
Test script:
---------------
<?php
var_dump(get_headers('http://localhost'));
Expected result:
----------------
The list of all headers..
or some error like "The php can not get the headers from localhohst" :D
Actual result:
--------------
The script run forever and ever.. (what a happy ending) ..'till the browser
dies.. (what a sad ending)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63106&edit=1