Bug #69825 [NEW]: Comparison syntax change?
| From: | michael dot babker at gmail dot com | Date: | Sat, 13 Jun 2015 23:22:32 +0000 |
| Subject: | Bug #69825 [NEW]: Comparison syntax change? | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-193436@lists.php.net to get a copy of this message | ||
From: michael dot babker at gmail dot com
Operating system: Debian
PHP version: 7.0Git-2015-06-13 (Git)
Package: Unknown/Other Function
Bug Type: Bug
Bug description:Comparison syntax change?
Description:
------------
Through a change made between June 09 and June 13, it appears a B/C
breaking change in comparison syntax was made. On PHP 7 builds from
June 09 and earlier, the following if statement correctly evaluated:
// $options['driver'] is set to 'sqlite' in the test environment
if ($options['driver'] === 'mysql' && PHP_MAJOR_VERSION >= 7)
As of today, if either condition in this statement evaluates to true it
is being interpreted as true and the code inside the conditional being
executed.
Test script:
---------------
The snippet above comes from Joomla's 3.5 development branch,
specifically the JDatabaseDriver::getInstance() method
(https://github.com/joomla/joomla-cms/blob/3.5-dev/libraries/joomla/database/driver.php#L251).
From a Travis-CI build using PHP 7 built on May 25, there is no issue
with this method (see
https://travis-ci.org/joomla/joomla-cms/jobs/64725678).
With a build
from today (see https://travis-ci.org/joomla/joomla-cms/jobs/66699284),
there are numerous failures relating to code attempting to fetch a
database driver. Our unit tests are configured to default to a SQLite
in-memory database and should not be reaching the MySQL driver.
I also tested with the following modification to getInstance on the
current Git build and this change passes without an issue -
https://gist.github.com/mbabker/f7f87195b31c597bd92e
Expected result:
----------------
When $options['driver'] === 'sqlite' and executed on a PHP 7 build, this
if conditional should evaluate to false:
if ($options['driver'] === 'mysql' && PHP_MAJOR_VERSION >= 7)
Actual result:
--------------
When $options['driver'] === 'sqlite' and executed on a PHP 7 build, this
if conditional is evaluating to true:
if ($options['driver'] === 'mysql' && PHP_MAJOR_VERSION >= 7)
--
Edit bug report at https://bugs.php.net/bug.php?id=69825&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69825&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69825&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69825&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69825&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69825&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69825&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69825&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69825&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69825&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69825&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69825&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69825&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69825&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69825&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69825&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69825&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69825&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69825&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69825&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69825&r=mysqlcfg