php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74344 isset() returns inncorect value
Submitted: 2017-03-30 15:55 UTC Modified: 2017-04-23 04:22 UTC
From: damianboni at gmail dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 7.0.15 OS: ubuntu 16.04.3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
25 - 11 = ?
Subscribe to this entry?

 
 [2017-03-30 15:55 UTC] damianboni at gmail dot com
Description:
------------
Tested on PHP7.0.8 ubuntu 16.04.3 @ 2017-03-30

isset() is incorrectly retuning false (should return true) when checking array key that has its value set to boolean.

I tested the below script on different version of PHP and always get true with an exception to 7.0.8


Test script:
---------------
Code:
$params['entry']['attributes'] = array(
    'enabled' => true
);

var_dump(isset($params['entry']['attributes']['enabled']));

$whatIsGoingOn = $params['entry']['attributes']['enabled'];

var_dump(isset($whatIsGoingOn));

var_dump(array_key_exists('enabled', $params['entry']['attributes']));

Output:
bool(false) 
bool(true) 
bool(true)

Expected result:
----------------
bool(true) 
bool(true) 
bool(true)

Actual result:
--------------
bool(false) 
bool(true) 
bool(true)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-30 16:04 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2017-03-30 16:04 UTC] requinix@php.net
Seems to working fine. https://3v4l.org/uKiR6

You tried with that *exact* script? Are you using any zend_extensions? Any difference with opcache enabled and disabled?
 [2017-03-30 16:07 UTC] spam2 at rhsoft dot net
> always get true with an exception to 7.0.8
reported for PHP Version: 7.0.17

so what does that mean?

"I tested the below script on different version of PHP and always get true with an exception to 7.0.8" - m yunderstanding is that this only happens on the Ubuntu build, not with a recent PHP release and so is not a current upstream pug?
 [2017-03-30 16:32 UTC] damianboni at gmail dot com
-Status: Feedback +Status: Open
 [2017-03-30 16:32 UTC] damianboni at gmail dot com
Issue occurs on version 7.0.8 , you're testing it on 5.6.X
 [2017-03-30 16:39 UTC] requinix@php.net
-Status: Open +Status: Not a bug -PHP Version: 7.0.17 +PHP Version: 7.0.8
 [2017-03-30 16:39 UTC] requinix@php.net
No, that link tests all recent versions of PHP. Read the page.

If it works in all versions except 7.0.8 then there's nothing to do because that's an old version and we're on 7.0.17 now. Can't go back in time.
Though I still doubt this problem actually exists.
 [2017-04-10 16:06 UTC] damianboni at gmail dot com
-PHP Version: 7.0.8 +PHP Version: 7.0.15
 [2017-04-10 16:06 UTC] damianboni at gmail dot com
Same issue experienced on Ubuntu 16.04 and PHP 7.0.15 and 7.1.3,
BUG:
isset is returning false when checking on boolean, this is inncorect, isset should return true on boolean value.


var_dump($sectionName);
var_dump(isset($params['entry']['attributes']['enabled']));
var_dump($params['entry']['attributes']['enabled']);

output:
string(4) "team"
bool(false)
bool(true)
 [2017-04-10 16:11 UTC] requinix@php.net
-Status: Not a bug +Status: Feedback
 [2017-04-10 16:11 UTC] requinix@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2017-04-23 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-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 22 12:01:30 2024 UTC