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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dmitriy dot trt at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC