|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69825 Short-circuiting failure
Submitted: 2015-06-13 23:22 UTC Modified: 2015-06-14 00:05 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: michael dot babker at gmail dot com Assigned: bwoebi (profile)
Status: Closed Package: Unknown/Other Function
PHP Version: 7.0Git-2015-06-13 (Git) OS: Debian
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: michael dot babker at gmail dot com
New email:
PHP Version: OS:


 [2015-06-13 23:22 UTC] michael dot babker at gmail dot com
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 (  From a Travis-CI build using PHP 7 built on May 25, there is no issue with this method (see  With a build from today (see, 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 -

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) 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-13 23:36 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: bwoebi
 [2015-06-13 23:36 UTC]
Simpler reproduce case

var_dump(0 && 1); // bool(true)

Going to fix that...
 [2015-06-14 00:05 UTC]
-Summary: Comparison syntax change? +Summary: Short-circuiting failure -Status: Assigned +Status: Closed
 [2015-06-14 00:05 UTC]
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

 For Windows:
Thank you for the report, and for helping us make PHP better.

Fixed via;a=commitdiff;h=f263932f38990ebee1353c8196deff440c3397d4
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 24 01:01:31 2024 UTC