Bug #69983 [Ver]: get_browser fails on 7.0 with user agent of null works on 5.6.10

From: Date: Fri, 03 Jul 2015 22:51:01 +0000
Subject: Bug #69983 [Ver]: get_browser fails on 7.0 with user agent of null works on 5.6.10
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194111@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69983&edit=1

 ID:                 69983
 Updated by:         kalle@php.net
 Reported by:        php7testing at prodpartners dot com
 Summary:            get_browser fails on 7.0 with user agent of null
                     works on 5.6.10
 Status:             Verified
 Type:               Bug
 Package:            Unknown/Other Function
 Operating System:   *
 PHP Version:        7.0.0alpha2
-Assigned To:        laruence
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

Christoph, I think its the conditional that is wrong, instead of || after the zend_is_auto_global()
call, use &&, like other places where the same code is used seems right, but so far I cannot
properly test since I only got CLI available.

(Assigned it to you, to notice this comment)


Previous Comments:
------------------------------------------------------------------------
[2015-07-03 18:42:25] cmb@php.net

The following patch has been added/updated:

Patch Name: bug69983.phpt
Revision:   1435948945
URL:        https://bugs.php.net/patch-display.php?bug=69983&patch=bug69983.phpt&revision=1435948945

------------------------------------------------------------------------
[2015-07-03 17:29:41] cmb@php.net

There seems to be a logic error in the detection of the user
agent[1]. zend_is_auto_global_str(ZEND_STRL("_SERVER"))) yields 1,
and so the error is triggered.

Is it supposed to be
!zend_is_auto_global_str(ZEND_STRL("_SERVER")))?

@laruence: Can you please have a look at the issue?

[1] <http://lxr.php.net/xref/PHP_TRUNK/ext/standard/browscap.c#465>

------------------------------------------------------------------------
[2015-07-03 16:41:24] cmb@php.net

I can confirm this issue for PHP 7.0.0-alpha2 with the CLI server
on Windows. Works fine with PHP 5.6.10, though. I'll do some
debugging.

------------------------------------------------------------------------
[2015-07-03 16:17:32] php7testing at prodpartners dot com

Perhaps I did not make it clear.  The problem only exists when you use a value of NULL for the user
agent parameter.  It works when I provide $_SERVER["HTTP_USER_AGENT"] for that parameter. 

I don't think that the problem has anything to do with the fastcgi configuration because of two
reasons:
1) I am using Apache 2.4 and php-fpm not nginx
2) It works with the same configuration on the same machine under 5.6.8

The following is the output when I first echo $_SERVER["HTTP_USER_AGENT"] and then call
get_browser(NULL, true).  I included 2 "<br>" after echoing
$_SERVER["HTTP_USER_AGENT"] to delineate that output from that of get_browser.

Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0

Warning: get_browser(): HTTP_USER_AGENT variable is not set, cannot determine user agent name in
/usr/local/apache2/htdocs/php7testing/browscap_test.php on line 3

The main reason that I am bringing this up is that PHP 7 behavior is different from 5.6 and from the
documentation.  I am trying to help eliminate problems for others making the transition from 5.X to
7.

------------------------------------------------------------------------
[2015-07-03 14:19:21] laruence@php.net

you can check $_SERVER["HTTP_USER_AGENT"] by dumping it before calling get_browse, this
probably relates to some issue of your configuration in nginx fastcgi params

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


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=69983


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


Thread (12 messages)

« previous php.bugs (#194111) next »