Bug #69074 [NEW]: array_filter do not clearing empty items.
| From: | oleg dot briareos17 at gmail dot com | Date: | Wed, 18 Feb 2015 17:05:18 +0000 |
| Subject: | Bug #69074 [NEW]: array_filter do not clearing empty items. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-190790@lists.php.net to get a copy of this message | ||
From: oleg dot briareos17 at gmail dot com
Operating system: Windows 8.1 (Open Server)
PHP version: 5.4.37
Package: Arrays related
Bug Type: Bug
Bug description:array_filter do not clearing empty items.
Description:
------------
$report['errors']['linkedin'][] =
CLinkedinApiHelper::api()->postToGroup('',$article['title'],
$description, $content);
array_filter($report['errors']['linkedin']);
when function return's nothing, array creating new item
$report['errors']['linkedin'][0] => null, but array_filter do not react
on it, it is only react when function return null directly.
Test script:
---------------
$report['errors']['linkedin'][] =
CLinkedinApiHelper::api()->postToGroup('',$article['title'],
$description, $content);
//part of helper function:
if ($data['linkedin']) {
$xml = simplexml_load_string($data['linkedin']);
if (isset($xml->{'error-code'})) {
$message = sprintf($xml->message);
return $message;
}
}
return null; //if remove this, array_filter do not see new "NULL" array
item
array_filter($report['errors']['linkedin']);
Expected result:
----------------
array(0) {}
Actual result:
--------------
array(1) {
[0]=>
NULL
}
--
Edit bug report at https://bugs.php.net/bug.php?id=69074&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69074&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69074&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69074&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69074&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69074&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69074&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69074&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69074&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69074&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69074&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69074&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69074&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69074&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69074&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69074&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69074&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69074&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69074&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69074&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69074&r=mysqlcfg