php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66524 Short-hand ternary operator broken for variables (on LiteSpeed server)
Submitted: 2014-01-20 18:13 UTC Modified: 2016-04-03 04:22 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: ante dot vrli at gmail dot com Assigned:
Status: No Feedback Package: Variables related
PHP Version: 5.4.24 OS: Linux 2.6.32
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ante dot vrli at gmail dot com
New email:
PHP Version: OS:

 

 [2014-01-20 18:13 UTC] 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"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-01-21 18:23 UTC] rasmus@php.net
-Status: Open +Status: Analyzed
 [2014-01-21 18:23 UTC] 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.
 [2016-03-26 23:15 UTC] nikic@php.net
-Status: Analyzed +Status: Feedback
 [2016-03-26 23:15 UTC] nikic@php.net
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.
 [2016-04-03 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Dec 08 13:03:41 2021 UTC