|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74732 Boolean and int values are not implicitly cast during comparison
Submitted: 2017-06-09 18:56 UTC Modified: 2017-07-19 09:15 UTC
From: smorozov at sugarcrm dot com Assigned:
Status: Open Package: ibm_db2 (PECL)
PHP Version: 7.1.6 OS: Ubuntu 16.04
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2017-06-09 18:56 UTC] smorozov at sugarcrm dot com
In PHP 5.6, if a boolean value is compared with an int, it's cast to int, so true == 1 and false == 0. In PHP 7.0 and 7.1, the comparison true == 1 returns false.

The script below works as expected on PHP 5.6 but doesn't on PHP 7.

Unlike, this behavior doesn't depend on whether Opcache is enabled or not.

Test script:
$dsn = 'HOSTNAME=localhost;UID=db2inst1;PWD=Passw0rd;DATABASE=test';
$conn = db2_connect($dsn, null, null);

if (!$conn) {
    echo db2_conn_errormsg(), PHP_EOL;

$stmt = db2_prepare($conn, 'SELECT 1 FROM SYSIBM.SYSDUMMY1 WHERE 1 = ?');

db2_execute($stmt, [true]);

db2_execute($stmt, [1]);

Expected result:
array(1) {
array(1) {

Actual result:
array(1) {


boolean_path (last revision 2017-07-17 08:39 UTC) by

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-13 11:15 UTC]
-Status: Open +Status: Assigned
 [2017-07-13 11:15 UTC]
Our developer Abhinav Radke from IBM is working on this defect. HE is able to reproduce the issue, he is reaching out to the zend guys to fix the issue. Will update once he has the solution for this issue.
 [2017-07-17 08:39 UTC]
The following patch has been added/updated:

Patch Name: boolean_path
Revision:   1500280746
 [2017-07-17 08:40 UTC]
  Our developer has fixed the issue. Please use the below patch to fix the problem.
 [2017-07-19 09:15 UTC] smorozov at sugarcrm dot com
Thank you! It works with the patch.
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Thu Jun 21 12:01:57 2018 UTC