php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57553 Testing for existing xml elements fails
Submitted: 2007-03-01 09:59 UTC Modified: 2017-01-10 08:05 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: cdouglas at securustech dot net Assigned:
Status: Suspended Package: SCA_SDO (PECL)
PHP Version: 5.2.1 OS: RHEL 4 U2
Private report: No CVE-ID: None
 [2007-03-01 09:59 UTC] cdouglas at securustech dot net
Description:
------------
I have an application where I am loading an XSD into the XML DAS and loading an XML file.  I am then trying to determine if an element of the XML file exists using isset with xpath path.  I am seeing that true is always returned, even when it doesn't exist. 



Reproduce code:
---------------
<sites>
<site id ='12345'>
<extendedData dataType='name'>South Central</extendedData>
<extendedData dataType='timezone'>US/Central</extendedData>
</site>
<site id='23456'>
</site>
</sites>

-----
load xml into $doc

isset($doc["site[id='12345']/extendedData[dataType='blah']"]) 

Expected result:
----------------
statement returns false

Actual result:
--------------
statement returns true

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-10 13:14 UTC] simonslaws at googlemail dot com
What is happening here is that SDO is raising an index out of bounds exception in trying to process dataType='blah' because the list index doesn't exist. SDO has to differentiate between  properties that don't exist and properties that exist but are set to null. Hence exceptions are called on to help out. 

Throwing exceptions inside isset() seems to make it return true which is a little strange but having said that I'm not sure what the right answer is other than catching the exception and ignoring what isset() returns. If noting else we need to improve the documentation aboutthe expected results of indexing properties that might or might not exist.

Chris has susequently posted a work round he has found to work in his situation (http://groups.google.co.uk/group/phpsoa/browse_frm/thread/6da0659c0a7adbff/?hl=en#)
 [2007-04-27 08:07 UTC] cem@php.net
There are quite a few peculiarities here, so I'm starting at the top with the problem that Tuscany is returning false positives to isset when a xpath ends with a list index. Most of the other inconsistencies hinge on this behaviour. See https://issues.apache.org/jira/browse/TUSCANY-1236
 [2017-01-10 08:05 UTC] kalle@php.net
-Status: Assigned +Status: Suspended -Assigned To: tuscany 1236 +Assigned To:
 [2017-01-10 08:05 UTC] kalle@php.net
Suspending this report as the extension have not had a release for almost 9 years.  Please revive this if the extension once again shows life
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 11:01:30 2024 UTC