Bug #66524 [Ana->Fbk]: Short-hand ternary operator broken for variables (on LiteSpeed server)
| From: | nikic@php.net | Date: | Sat, 26 Mar 2016 23:15:42 +0000 |
| Subject: | Bug #66524 [Ana->Fbk]: Short-hand ternary operator broken for variables (on LiteSpeed server) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-200130@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66524&edit=1
ID: 66524
Updated by: nikic@php.net
Reported by: ante dot vrli at gmail dot com
Summary: Short-hand ternary operator broken for variables (on
LiteSpeed server)
-Status: Analyzed
+Status: Feedback
Type: Bug
Package: Variables related
Operating System: Linux 2.6.32
PHP Version: 5.4.24
Block user comment: N
Private report: N
New Comment:
Switching to Feedback, that's probably what was intended there. In the unlikely case that this
issue still exists in recent versions of PHP, please reopen the bug.
Previous Comments:
------------------------------------------------------------------------
[2014-01-21 18:23:27] rasmus@php.net
This seems extremely unlikely to me. The SAPI PHP is running under should have absolutely no effect
on the parsing barring some really weird memory corruption in Litespeed. Throw Valgrind at it and
see if that is the case but first triple-check that you are seeing what you think you are seeing.
------------------------------------------------------------------------
[2014-01-20 18:13:18] ante dot vrli at gmail dot com
Description:
------------
In short-hand ternary comparison, variables are always evaluated as false.
This bug was found in PHP versions 5.4.23 and 5.4.24, when running as a module on LiteSpeed server,
as compiled using EasyApache, but NOT when running in CLI. So it has to do with LiteSpeed, it seems,
but nevertheless the issue somehow compiles into a core PHP issue.
Configure command:
'./configure' '--disable-fileinfo' '--enable-bcmath'
'--enable-calendar' '--enable-exif' '--enable-ftp'
'--enable-gd-native-ttf' '--enable-libxml' '--enable-mbstring'
'--enable-pdo=shared' '--enable-soap' '--enable-sockets'
'--enable-wddx' '--enable-zip' '--prefix=/usr/local'
'--with-bz2' '--with-curl=/opt/curlssl/' '--with-curlwrappers'
'--with-freetype-dir=/usr' '--with-gd' '--with-gettext'
'--with-imap=/opt/php_with_imap_client/' '--with-imap-ssl=/usr'
'--with-jpeg-dir=/usr' '--with-kerberos' '--with-libdir=lib64'
'--with-libexpat-dir=/usr' '--with-libxml-dir=/opt/xml2'
'--with-libxml-dir=/opt/xml2/' '--with-mcrypt=/opt/libmcrypt/'
'--with-mm=/opt/mm/' '--with-mysql=/usr'
'--with-mysql-sock=/var/lib/mysql/mysql.sock'
'--with-mysqli=/usr/bin/mysql_config' '--with-openssl=/usr'
'--with-openssl-dir=/usr' '--with-pcre-regex=/opt/pcre'
'--with-pdo-mysql=shared' '--with-pdo-sqlite=shared' '--with-pic'
'--with-png-dir=/usr' '--with-pspell' '--with-tidy=/opt/tidy/'
'--with-xmlrpc!
' '--with-xpm-dir=/usr' '--with-xsl=/opt/xslt/' '--with-zlib'
'--with-zlib-dir=/usr' '--with-litespeed'
Test script:
---------------
$v = 'Correct';
echo ($v ? $v: 'Incorrect'); // Echoes "Correct"
echo ($v ?: 'Incorrect'); // Echoes "Incorrect"
Expected result:
----------------
"Correct Correct"
Actual result:
--------------
"Correct Incorrect"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66524&edit=1