php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67067 isset() and empty() on NULL value of the ArrayObject child class
Submitted: 2014-04-13 19:21 UTC Modified: 2014-05-08 17:11 UTC
From: dmitriy dot trt at gmail dot com Assigned:
Status: Duplicate Package: *General Issues
PHP Version: 5.4.27 OS: Windows 7 x86, Linux
Private report: No CVE-ID: None
 [2014-04-13 19:21 UTC] dmitriy dot trt at gmail dot com
Description:
------------
ArrayObject itself and child classes work fine until you override offsetExists() method, even with a method returning parent's results. Both isset() and empty() return incorrect results on NULL value set to the pseudo-array.

Reproducible on PHP 5.4.27, Windows 7 x86.

Test script:
---------------
http://pastebin.com/geNadPSA

Expected result:
----------------
array(2) {
  ["ArrayObject"]=>
  array(2) {
    ["empty"]=>
    bool(true)
    ["isset"]=>
    bool(false)
  }
  ["ArrayObjectOverride"]=>
  array(2) {
    ["empty"]=>
    bool(true)
    ["isset"]=>
    bool(false)
  }
}

Actual result:
--------------
array(2) {
  ["ArrayObject"]=>
  array(2) {
    ["empty"]=>
    bool(true)
    ["isset"]=>
    bool(false)
  }
  ["ArrayObjectOverride"]=>
  array(2) {
    ["empty"]=>
    bool(false)
    ["isset"]=>
    bool(true)
  }
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-05-08 17:11 UTC] levim@php.net
-Status: Open +Status: Duplicate
 [2014-05-08 17:11 UTC] levim@php.net
Closing as a duplicate of bug 66834.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Jun 21 17:01:23 2021 UTC