Bug #69825 [Asn->Csd]: Short-circuiting failure

From: Date: Sun, 14 Jun 2015 00:05:26 +0000
Subject: Bug #69825 [Asn->Csd]: Short-circuiting failure
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193438@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69825&edit=1 ID: 69825 Updated by: bwoebi@php.net Reported by: michael dot babker at gmail dot com -Summary: Comparison syntax change? +Summary: Short-circuiting failure -Status: Assigned +Status: Closed Type: Bug Package: Unknown/Other Function Operating System: Debian PHP Version: 7.0Git-2015-06-13 (Git) Assigned To: bwoebi Block user comment: N Private report: N New Comment: The fix for this bug has been committed. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. For Windows: http://windows.php.net/snapshots/ Thank you for the report, and for helping us make PHP better. Fixed via http://git.php.net/?p=php-src.git;a=commitdiff;h=f263932f38990ebee1353c8196deff440c3397d4 Previous Comments: ------------------------------------------------------------------------ [2015-06-13 23:36:41] bwoebi@php.net Simpler reproduce case var_dump(0 && 1); // bool(true) Going to fix that... ------------------------------------------------------------------------ [2015-06-13 23:22:31] michael dot babker at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=69825&edit=1

« previous php.bugs (#193438) next »