From:
Operating system: Windows
PHP version: 5.3.3
Package: Arrays related
Bug Type: Bug
Bug description:Accessing an ArrayAccess item directly
Description:
------------
I'm trying to get an item of an array by its key. The array is in fact a
SolrObject, which implements ArrayAccess, so I understand that I can access
its
items as I would in an array. This object is retrieved by the getResponse()
method of the SolrQueryResponse class
(php.net/manual/en/solrresponse.getresponse.php).
This is the structure of my $myobject:
SolrObject Object
(
[116809] => SolrObject Object
(
[title] => Array
(
[0] => First value
)
[description] => Array
(
[0] => Second value
)
)
[591978] => SolrObject Object
(
[title] => Array
(
[0] => Third value
)
[description] => Array
(
[0] => Forth value
)
)
)
So, if I try
var_dump($myobject[116809]);
I get NULL.
But if I try
echo array_key_exists(116809, $myobject);
I get 1
If I try to iterate $myobject with a foreach, I can access its elements
correctly.
Why can't I access directly one element by its key?
EDIT: Answering to @ircmaxell, this is the var_dump:
object(SolrObject)#219 (50) {
[116809]=>
object(SolrObject)#220 (2) {
["title"]=>
array(1) {
[0]=>
string(43) "First value"
}
["description"]=>
array(1) {
[0]=>
string(82) "Second value"
}
}
[591978]=>
object(SolrObject)#221 (2) {
["title"]=>
array(1) {
[0]=>
string(104) "Third value"
}
["description"]=>
array(1) {
[0]=>
string(95) "Fourth value"
}
}
}
And this is the result of var_dump($myobject->getPropertyNames());
array(2) {
[0]=>
string(0) ""
[1]=>
string(0) ""
}
--
Edit bug report at http://bugs.php.net/bug.php?id=53183&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=53183&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=53183&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=53183&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=53183&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=53183&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=53183&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=53183&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=53183&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=53183&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=53183&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=53183&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=53183&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=53183&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=53183&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53183&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53183&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=53183&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=53183&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=53183&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=53183&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=53183&r=mysqlcfg