#44411 [Com]: Broken Compatibility

2008-03-11 Thread hubert dot roksor at gmail dot com
 ID:   44411
 Comment by:   hubert dot roksor at gmail dot com
 Reported By:  phpbugs at steve dot ipapp dot com
 Status:   Open
 Bug Type: SimpleXML related
 Operating System: ANY
 PHP Version:  5.2.5
 New Comment:

As per the manual chapter you quoted, the comparison operator compares
_objects_, and that's the key word here. You expect two equal XML trees
to be represented by two equal objects, and even though this expectation
is understandable, it is simply not the case. Those objects are
different. In fact, even if $sax1->value is equal to $sax1->value and
they come from the same tree, they are not identical. ($sax1->value !==
$sax1->value)

The bottom line is the comparison operator compares objects. If you
need an operator that understands the underlying data you will have to
use another mean. The solution proposed in the other bug report (compare
them as XML strings) sounds reasonable.

It would be nice to mention this quirk in the manual though, perhaps as
a new example? "Comparing Elements and Elements"


Previous Comments:


[2008-03-12 01:35:37] phpbugs at steve dot ipapp dot com

Description:

In PHP 5.0.x and 5.1.x two SimpleXMLElement objects were considered
equal if they represented the same data.

In PHP 5.2.x this does not seem to be the case anymore. This was
previously listed as bug 39866 [http://bugs.php.net/bug.php?id=39866],
but for some reason this was listed as bogus.  In that bug it was noted
that we should look at Example 5 at http://php.net/simplexml. I'm
assuming this is Example 6 now [Comparing Elements and Attributes with
Text] , but this is incorrect as comparision will implicity cast 
it to string anyway.

According to
http://www.php.net/manual/en/language.oop5.object-comparison.php:
"When using the comparison operator (==), object variables are compared
in a simple manner, namely: Two object instances are equal if they have
the same attributes and values, and are instances of the same class...
On the other hand, when using the identity operator (===), object
variables are identical if and only if they refer to the same instance
of the same class." 

Furthermore this backwards incompatible change is not listed in :
http://us.php.net/manual/en/migration52.incompatible.php.

Currently there is no equals method that we can call to get the
previous functionality back, and at the present moment this makes == no
longer transitive as  especially since this makes == no longer
transitive as 'doc' == x1, 'doc' == x2, but x1 != x2. 

I do not understand why ==, nor do I see value in, doing a strict
comparison for SimpleXMLObjects as ==, when according to the PHP Object
Comparison manual this should be ===. 

Therefore I believe this is a bug.




Reproduce code:
---
$xmldoc = "foo";

$sax1 = new SimpleXMLElement("$xmldoc");
$sax2 = new SimpleXMLElement("$xmldoc");

if($sax1 == $sax2)
{
echo "TRUE";
} else
{
echo "FALSE";
}
echo "\n\n\n";


Expected result:

TRUE

Actual result:
--
FALSE





-- 
Edit this bug report at http://bugs.php.net/?id=44411&edit=1



#44108 [Com]: SimpleXMLelement has no children() on element with only attributes?

2008-02-13 Thread hubert dot roksor at gmail dot com
 ID:   44108
 Comment by:   hubert dot roksor at gmail dot com
 Reported By:  php dot net at trueprices dot net
 Status:   Open
 Bug Type: SimpleXML related
 Operating System: Debian
 PHP Version:  5.2.5
 New Comment:

If $child2 is  then $child3 will be  or
 and there will be no $child4.

Unless this behaviour is considered as a bug by the developer and until
it is fixed, you'll have to specify the children's namespace when
calling children():
- $child2->children('http://schemas.xmlsoap.org/wsdl/') on PHP 5.1 and
later or
- $child2->children('wsdl', true) on PHP 5.2 and later


Previous Comments:


[2008-02-13 12:47:53] php dot net at trueprices dot net

Description:

SimpleXMLelement has no children() on element with only attributes?

I try to retreive an element by xpath which goes without problems, The
child elements it contains (same namespace) are all empty element with
only attributes. However the returned SimpleXML element does not contain
any children? so i'm unable to retreive there attributes.




Reproduce code:
---

http://schemas.xmlsoap.org/wsdl/"; 
  targetNamespace="http://www.w3.org/2001/XMLSchema";
>










';

echo '';
$xml = simplexml_load_string($data);
if ($xml)
{

  $res2 = $xml->xpath('//wsdl:portType/wsdl:operation');
  //print_r($res);
  foreach ($res2 as $child2)
  {
//print_r($child2->children());
echo 'child2'.PHP_EOL;
print_r($child2->getName().PHP_EOL);
print_r(count($child2->children()).PHP_EOL);
print_r($child2);

foreach ($child2->children() as $child3)
{
  echo 'child3'.PHP_EOL;
  print_r($child3->getName().PHP_EOL);
  print_r(count($child3->children()).PHP_EOL);
  print_r($child3);
  foreach ($child3->children() as $child4)
  {
echo 'child4'.PHP_EOL;
print_r($child4->getName().PHP_EOL);
print_r(count($child4->children()).PHP_EOL);
print_r($child4);
  }
}

  }
}
echo '';
?>

Expected result:

child2 & child3 & child4 should be printed..
 

child2
operation
2
SimpleXMLElement Object
(
[EMAIL PROTECTED] => Array
(
[name] => SOAP_set
)

)
child2
operation
2
SimpleXMLElement Object
(
[EMAIL PROTECTED] => Array
(
[name] => SOAP_set
)
   /* 2 another simplexml element input & output with children &
attributes*/
)

Actual result:
--
Only child2 prints with 0 children

child2
operation
0
SimpleXMLElement Object
(
[EMAIL PROTECTED] => Array
(
[name] => SOAP_set
)

)
child2
operation
0
SimpleXMLElement Object
(
[EMAIL PROTECTED] => Array
(
[name] => SOAP_get
)

)





-- 
Edit this bug report at http://bugs.php.net/?id=44108&edit=1


#43778 [Com]: SimpleXML regression regarding empty() in 5.2.4

2008-01-07 Thread hubert dot roksor at gmail dot com
 ID:   43778
 Comment by:   hubert dot roksor at gmail dot com
 Reported By:  jdolecek at netBSD dot org
 Status:   Open
 Bug Type: SimpleXML related
 Operating System: Windows 2000
 PHP Version:  5.2.5
 New Comment:

Actually, this doesn't seem to be a regression but rather the intended
behaviour, as per this commit:
http://marc.info/?l=php-cvs&m=118352557820634&w=2

As per PHP's manual, empty() "[determines] whether a variable is
considered to be empty". $xml->items->item will return the first "item"
node, and since that node has no children and no content it is
considered empty. If you only want to test whether or not an element is
present, without inspecting its content, then you should use isset()
instead.

Hope that makes sense to you. Note: of course, this is only my personal
interpretation, nothing official.


Previous Comments:


[2008-01-07 17:22:11] jdolecek at netBSD dot org

Description:

It seems empty() on simplexml 'array' elements doesn't work same way in
5.2.5 as in 5.2.3. In 5.2.5, empty() returns true even through the
elements are actually present. Same code run under 5.2.3 works
correctly, i.e. returning true only if the element is not present.

Workaround is replace (!empty(...)) condition with isset() and test for
count(), but this is inconvenient and breaks backwards compatibility.

Reproduce code:
---














';

$xml = simplexml_load_string($str);

echo (empty($xml->items->item) ? "EMPTY" : "full")."\n";
echo count($xml->items->item) ."\n";


Expected result:

full
6

Actual result:
--
EMPTY
6





-- 
Edit this bug report at http://bugs.php.net/?id=43778&edit=1


#43542 [Com]: simpleXML thinks that comment is node

2007-12-09 Thread hubert dot roksor at gmail dot com
 ID:   43542
 Comment by:   hubert dot roksor at gmail dot com
 Reported By:  007not at gmail dot com
 Status:   Open
 Bug Type: SimpleXML related
 Operating System: win xp sp2
 PHP Version:  5.2.5
 New Comment:

Regarding your first test, I wouldn't consider that a bug. var_dump()
is a debugging tool, it may expose some of the behind-the-scene magic.
Actually, that "comment" property might have been intentionally created
as a way to indicate whether the node has a comment. That would explain
isset()'s behaviour in your third test, but in this case I would
recommand replacing that magical property with a method such as
$node->hasComment(). I guess Rob Richards will be able to shed some
light here.

As for your second test, I'm afraid it is incorrect: both $xml->node
and $xml->otherNode should return 1 element and I don't see why having a
comment as a child would change that.


Previous Comments:


[2007-12-09 11:02:10] 007not at gmail dot com

Description:

also see http://bugs.php.net/43392
>[EMAIL PROTECTED] comment:
>This is just normal and expected behaviour.
> is not same as .
>(try var_dump($xml); to see what happens)

i made some new test for you, and try to var_dump() this
var_dump(array(/*'comment' => 'value'*/));
 ===  && array(/*'comment' =>
'value'*/) === array('comment' => 'value')
is it still be same ? ;)

Reproduce code:
---
$string = <<

 
 
 value

XML;
$xml = simplexml_load_string($string);

//note: xdebug used

//first test
var_dump($xml->node);
var_dump($xml->otherNode);

/*
Expected result:

null

object(SimpleXMLElement)[2]
  public 'comment' => string 'value' (length=5)

Actual result:
--
object(SimpleXMLElement)[2]
  public 'comment' =>
object(SimpleXMLElement)[4]

object(SimpleXMLElement)[2]
  public 'comment' => string 'value' (length=5)
*/



//second test
$i = 0;
foreach ($xml->node as $node)
{
$i++;
}
echo $i . "\n";

$i = 0;
foreach ($xml->otherNode as $node)
{
$i++;
}
echo $i . "\n";

/*
Expected result:

0
1

Actual result:
--
1
1
*/

//third test
var_dump($xml->node->comment);
var_dump($xml->otherNode->comment);

//check magic
echo "node:\n";
if (is_object($xml->node->comment))
{
echo "is_object === TRUE \n";
}
if (isset($xml->node->comment))
{
echo "isset === TRUE \n";
}
//but
if (strlen($xml->node->comment) > 0)
{
echo "strlen > 0\n";
}
if (strlen($xml->node->comment) == 0)
{
echo "strlen == 0\n";
}

echo "otherNode:\n";
if (is_object($xml->otherNode->comment))
{
echo "is_object === TRUE \n";
}
if (isset($xml->otherNode->comment))
{
echo "isset === TRUE \n";
}

/*
Expected result:

node:
is_object === TRUE
isset === TRUE
strlen == 0
otherNode:
is_object === TRUE

Actual result:
--
node:
is_object === TRUE
strlen == 0
otherNode:
is_object === TRUE
*/

Expected result:

see code

Actual result:
--
see code





-- 
Edit this bug report at http://bugs.php.net/?id=43542&edit=1


#43221 [Com]: SimpleXML cannot handle multiple attribute namespaces

2007-11-12 Thread hubert dot roksor at gmail dot com
 ID:   43221
 Comment by:   hubert dot roksor at gmail dot com
 Reported By:  jevon at jevon dot org
 Status:   Assigned
 Bug Type: SimpleXML related
 Operating System: Windows XP
 PHP Version:  5.2.4
 Assigned To:  rrichards
 New Comment:

It works just fine if you define your namespace beforehand.

$xml = new SimpleXMLElement('http://bar.com"/>');
$n = $xml->addChild("node", "value");
$n->addAttribute("a", "b");
$n->addAttribute("c", "d", "http://bar.com";);
print_r($xml->asXml());

I don't know, perhaps SimpleXML should raise a E_NOTICE on unknown
namespace, but it's really a matter of good coding practice.

Btw, jevon, I don't recommend saying that something is "screwy" when
filing bug reports, it doesn't really motivate developpers of said
software to look into them ^^;


Previous Comments:


[2007-11-12 09:55:18] [EMAIL PROTECTED]

Rob, could you take a look at it plz?



[2007-11-09 02:48:17] jevon at jevon dot org

Description:

Namespace support in SimpleXML is all screwy. In particular, you cannot
add two differently-namespaced attributes to a SimpleXML node; the first
one is lost.

Reproduce code:
---
$xml = new SimpleXMLElement('');
$n = $xml->addChild("node", "value");// still fails even if we set
a NS here
$n->addAttribute("a", "b");// still fails even if we set a
different NS here
$n->addAttribute("c", "d", "http://bar.com";);
print_r($xml->asXml());

Expected result:

http://bar.com";>value

Actual result:
--
http://bar.com"; a="b" c="d">value





-- 
Edit this bug report at http://bugs.php.net/?id=43221&edit=1


#42571 [Com]: Method variable array's missing

2007-09-09 Thread hubert dot roksor at gmail dot com
 ID:   42571
 Comment by:   hubert dot roksor at gmail dot com
 Reported By:  rockerboo at gmail dot com
 Status:   Feedback
 Bug Type: SimpleXML related
 Operating System: CentOS 5
 PHP Version:  5.2.4
 New Comment:

This is not a bug. The reporter expects is_array() to return true when
passed a SimpleXML_Element object.

@rockerboo: even though you can access a SimpleXML_Element as an array,
it doesn't mean that it is considered as an array, therefore is_array()
is expected to return false.


Previous Comments:


[2007-09-06 22:38:50] [EMAIL PROTECTED]

Please, try come up with shorter script that clearly (!) shows the
problem you have. (without the extra empty lines please)



[2007-09-06 10:43:35] [EMAIL PROTECTED]

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with ,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.





[2007-09-05 20:01:16] rockerboo at gmail dot com

Description:

I create an SimpleXmlElement, and see if one of the member variable
array's in an array, and it says it is not. But I am able to foreach
through the array, and when I do, the key states they 2nd parent's key
as the key. 

Linux virbdevel.com 2.6.18-8.1.4.el5.028stab035.1 #1 SMP Sat Jun 9
01:43:20 MSD 2007 i686

'./configure' '--with-apxs2=/usr/sbin/apxs'
'--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d'
'--libdir=/usr/lib' '--with-libdir=lib' '--with-mysql' '--with-mysqli'
'--with-pear' '--with-zlib' '--with-openssl' '--with-png'
'--with-jpeg-dir=/usr/lib' '--with-bz2' '--enable-bcmath'
'--enable-exif' '--with-fam' '--with-gd' '--enable-gd-native-ttf'
'--with-freetype-dir=/usr/lib' '--enable-gd-jis-conv' '--with-imap'
'--with-imap-ssl' '--enable-mbstring' '--with-iconv' '--with-mcrypt'
'--enable-shmop' '--enable-imap' '--enable-imap-ssl' '--with-kerberos'
'--with-xsl' '--with-dom' '--enable-soap' '--enable-simplexml'
'--with-mhash' '--with-curl' '--enable-calendar' '--enable-dbx'
'--with-xml' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg'
'--enable-track-vars' '--enable-trans-sid' '--enable-sockets'
'--enable-exif' '--enable-ftp' '--enable-magic-quotes'
'--disable-ffmpeg'

Reproduce code:
---
http://pastebin.com/f252f4872

Expected result:


SimpleXMLElement Object
(
[EMAIL PROTECTED] => Array
(
[type] => array
)

[status] => Array
(
[0] => SimpleXMLElement Object
(
[created_at] => Wed Sep 05 18:06:54 + 2007
[id] => 249403592
[text] => Everyone that gets the new iPod Touch
automatically receives a iPhone Wannabe t-shirt and decal.
[source] => twitterrific
[user] => SimpleXMLElement Object
(
[id] => 5871202
[name] => Brad
[screen_name] => stillframe
[location] => Boston, USA
[description] => drunk and in jail for
arson
[profile_image_url] =>
http://assets1.twitter.com/system/user/profile_image/5871202/normal/noobbrad_x150.jpg?1187756051
[url] => http://stillframe.com
[protected] => false
)

)

[1] => SimpleXMLElement Object
(
[created_at] => Wed Sep 05 18:02:46 + 2007
[id] => 249393302
[text] => iPodTouch? No. iPodBadTouch. Don't touch
your iPod that way.
[source] => twitterrific
[user] => SimpleXMLElement Object
(
[id] =&

#41955 [NEW]: addChild() with no namespace defined ignores the default namespace

2007-07-10 Thread hubert dot roksor at gmail dot com
From: hubert dot roksor at gmail dot com
Operating system: 
PHP version:  5CVS-2007-07-10 (snap)
PHP Bug Type: SimpleXML related
Bug description:  addChild() with no namespace defined ignores the default 
namespace

Description:

When adding a non-namespaced element to namespaced one, the new element is
created under its parent's namespace instead of the scope's default
namespace.

In the reproduce code below we create a tree whose root element carries an
empty default namespace declaration, with one "child" element under a
custom namespace. We use addChild() to add a grandchild with no namespace
defined. As per my understanding of XML Namespaces specifications, that
element should be created under the default namespace and since the default
namespace is empty the element should not use any namespace at all.

A few notes:
- moving the default namespace declaration to the child node does not
change the outcome
- using a non-empty default namespace does not change the outcome
- specifying an empty namespace using addChild()'s third parameter gives
the expected result

Tested on:
PHP 5.2.4-dev (cli) (built: Jul 10 2007 12:04:20)
libXML Version => 2.6.26
SimpleXML Revision => $Revision: 1.151.2.22.2.33 $

Thanks for reading, and thanks for fixing my previous bugs so quickly ;)

Reproduce code:
---

http://myns"; xmlns="">

');

$children = $xml->children('http://myns');
$children[0]->addChild('grandchild', 'hello');

echo $xml->asXML();

?>

Expected result:


http://myns"; xmlns="">
hello


Actual result:
--

http://myns"; xmlns="">
hello


-- 
Edit bug report at http://bugs.php.net/?id=41955&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=41955&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=41955&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=41955&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41955&r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=41955&r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=41955&r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=41955&r=needscript
Try newer version:http://bugs.php.net/fix.php?id=41955&r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=41955&r=support
Expected behavior:http://bugs.php.net/fix.php?id=41955&r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=41955&r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=41955&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41955&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=41955&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41955&r=dst
IIS Stability:http://bugs.php.net/fix.php?id=41955&r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=41955&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=41955&r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=41955&r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=41955&r=mysqlcfg


#41947 [NEW]: SimpleXML incorrectly registers empty strings as namespaces

2007-07-10 Thread hubert dot roksor at gmail dot com
From: hubert dot roksor at gmail dot com
Operating system: 
PHP version:  5CVS-2007-07-10 (snap)
PHP Bug Type: SimpleXML related
Bug description:  SimpleXML incorrectly registers empty strings as namespaces

Description:

As per XML Namespaces specifications, "The attribute value in a default
namespace declaration MAY be empty. This has the same effect, within the
scope of the declaration, of there being no default namespace." (source:
http://www.w3.org/TR/REC-xml-names/#defaulting) However, when creating
elements using an empty string as namespace, SimpleXML seems to register
the empty string as a namespace instead of just removing any inherited
namespace.

In the reproduce code below, we generate an empty tree to which we add a
new element "child" in the namespace "http://myns";. Then we add an element
"grandchild" (whose content will be "hello") to that element using an empty
string as namespace so that "grandchild" does not inherit "http://myns"; as
namespace. Then we attempt to transform the tree using XSLT, and verify
grandchild's namespaces with getNamespaces().

Apparently, it is impossible to access "grandchild" in XSL because it
belongs to an empty namespace using an empty prefix (as shown with
getNamespaces()). Reloading the tree by dumping it as XML then reparsing it
with simplexml_load_string() circumvents that bug.

Tested on:
PHP 5.2.4-dev (cli) (built: Jul 10 2007 00:04:16)
libXML Version => 2.6.26
SimpleXML Revision => $Revision: 1.151.2.22.2.32 $
libxslt Version => 1.1.17

Reproduce code:
---
http://myns"; />');
$grandchild = $xml->addChild('child', null,
'http://myns')->addChild('grandchild', 'hello', '');

$xslt = new XSLTProcessor;
$xslt->importStylesheet(simplexml_load_string('
http://www.w3.org/1999/XSL/Transform"; xmlns:myns="http://myns";>


[]


'));

echo 'output before reload: ', $xslt->transformToXML($xml), "namespaces:
", print_r($grandchild->getNamespaces(), true);

$xml = simplexml_load_string($xml->asXML());
$children = $xml->children('http://myns');
$grandchild = $children[0]->grandchild;

echo "\noutput after reload: ", $xslt->transformToXML($xml), "namespaces:
", print_r($grandchild->getNamespaces(), true);
?>

Expected result:

output before reload: 

[hello]

namespaces: Array
(
)

output after reload: 

[hello]

namespaces: Array
(
)

Actual result:
--
output before reload: 

[]

namespaces: Array
(
[] =>
)

output after reload: 

[hello]

namespaces: Array
(
)

-- 
Edit bug report at http://bugs.php.net/?id=41947&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=41947&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=41947&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=41947&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41947&r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=41947&r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=41947&r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=41947&r=needscript
Try newer version:http://bugs.php.net/fix.php?id=41947&r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=41947&r=support
Expected behavior:http://bugs.php.net/fix.php?id=41947&r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=41947&r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=41947&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41947&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=41947&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41947&r=dst
IIS Stability:http://bugs.php.net/fix.php?id=41947&r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=41947&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=41947&r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=41947&r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=41947&r=mysqlcfg


#41861 [NEW]: getNamespaces() returns the namespaces of a node's siblings

2007-06-30 Thread hubert dot roksor at gmail dot com
From: hubert dot roksor at gmail dot com
Operating system: 
PHP version:  5CVS-2007-06-30 (CVS)
PHP Bug Type: SimpleXML related
Bug description:  getNamespaces() returns the namespaces of a node's siblings

Description:

In addition to a node's own namespaces, getNamespaces() seems to return
the namespaces of its latter siblings.

In the reproduce code below, we create a tree composed of 5 nodes: the
first and last nodes have no namespaces and the 3 nodes in-between each
have their own namespace. We observe that getNamespaces() returns all 3
namespaces for the first node, altough it should have none, then 3, 2, 1
namespaces for the subsequent nodes (which should only have one each) then
finally no namespace for the last node, as expected.

children(), on the other hand, behaves correctly and does not find the
nodes under those "extra" namespaces so I guess the problem is located in
getNamespaces().

Thanks for reading :]


Tested on:

PHP 5.2.4-dev (cli) (built: Jun 30 2007 12:04:20)
WinXP
libxml2 2.6.26
SimpleXML Revision: 1.151.2.22.2.29

PHP 5.2.2-pl1-gentoo (cli) (built: May 24 2007 00:26:35)
libxml 2.6.27
SimpleXML Revision: 1.151.2.22.2.26

Reproduce code:
---
$xml = simplexml_load_string('






');

foreach (array(null, '#ns1', '#ns2', '#ns3') as $ns)
{
foreach ($xml->children($ns) as $child)
{
$name = $child->getName();
$namespaces = $child->getNamespaces(false);

echo "children($ns) has found '$name' -- Its namespaces: ", 
implode(',
', $namespaces), "\n";
}
}

Expected result:

children() has found 'first_node_no_ns' -- Its namespaces: #ns1, #ns2,
#ns3
children() has found 'last_node_no_ns' -- Its namespaces:
children(#ns1) has found 'node1' -- Its namespaces: #ns1, #ns2, #ns3
children(#ns2) has found 'node2' -- Its namespaces: #ns2, #ns3
children(#ns3) has found 'node3' -- Its namespaces: #ns3

Actual result:
--
children() has found 'first_node_no_ns' -- Its namespaces:
children() has found 'last_node_no_ns' -- Its namespaces:
children(#ns1) has found 'node1' -- Its namespaces: #ns1
children(#ns2) has found 'node2' -- Its namespaces: #ns2
children(#ns3) has found 'node3' -- Its namespaces: #ns3

-- 
Edit bug report at http://bugs.php.net/?id=41861&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=41861&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=41861&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=41861&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41861&r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=41861&r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=41861&r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=41861&r=needscript
Try newer version:http://bugs.php.net/fix.php?id=41861&r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=41861&r=support
Expected behavior:http://bugs.php.net/fix.php?id=41861&r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=41861&r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=41861&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41861&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=41861&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41861&r=dst
IIS Stability:http://bugs.php.net/fix.php?id=41861&r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=41861&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=41861&r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=41861&r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=41861&r=mysqlcfg


#41833 [NEW]: addChild() on a non-existent node, no node created, getName() segfaults

2007-06-27 Thread hubert dot roksor at gmail dot com
From: hubert dot roksor at gmail dot com
Operating system: 
PHP version:  5CVS-2007-06-28 (snap)
PHP Bug Type: SimpleXML related
Bug description:  addChild() on a non-existent node, no node created, getName() 
segfaults

Description:

addChild() does not behave as expected(?) when used on a node that wasn't
previously declared.

In the example below, we initialize an empty tree, to which we attempt to
add a new node at "/child/grandchild" without previously adding "child" to
the tree. addChild() seems to operate on a temporary SimpleXMLElement and
the changes are never applied to the original object/tree.

I believe that this bug is also responsible of the segfault that happens
if getName() is used on the temporary SimpleXMLElement. I was very tempted
to file this bug as a reproducible crash, but decided to file it under
SimpleXML in case it would help routing it to the maintainer faster.


Tested on:

PHP 5.2.4-dev (cli) (built: Jun 27 2007 20:04:30)
WinXP
libxml2 2.6.26
SimpleXML Revision: 1.151.2.22.2.29

PHP 5.2.2-pl1-gentoo (cli) (built: May 24 2007 00:26:35)
libxml 2.6.27
SimpleXML Revision: 1.151.2.22.2.26

Reproduce code:
---
');
$xml->child->addChild('grandchild');

echo $xml->asXML();

Expected result:

I expect SimpleXML to create "child" if it does not exist, then add
"grandchild" to that node. The output should be:




Actual result:
--
Neither node is added to the tree. The output is:




-- 
Edit bug report at http://bugs.php.net/?id=41833&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=41833&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=41833&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=41833&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41833&r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=41833&r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=41833&r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=41833&r=needscript
Try newer version:http://bugs.php.net/fix.php?id=41833&r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=41833&r=support
Expected behavior:http://bugs.php.net/fix.php?id=41833&r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=41833&r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=41833&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41833&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=41833&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41833&r=dst
IIS Stability:http://bugs.php.net/fix.php?id=41833&r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=41833&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=41833&r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=41833&r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=41833&r=mysqlcfg


#40752 [NEW]: parse_ini_file() segfaults when a scalar setting is redeclared as an array

2007-03-07 Thread hubert dot roksor at gmail dot com
From: hubert dot roksor at gmail dot com
Operating system: 
PHP version:  5.2.1
PHP Bug Type: Reproducible crash
Bug description:  parse_ini_file() segfaults when a scalar setting is 
redeclared as an array

Description:

Using [] in a key name can result in a crash if the corresponding setting
was previously set to a scalar value.

Reproduce code:
---
// Not relevant to the bug
$file = tempnam('./', '');
file_put_contents($file, '
foo  =1;
foo[]=1;
');

// Will make PHP crash
parse_ini_file($file);


Expected result:

In the attached reproduce code we create a ini file which has 2 keys,
"foo" and "foo[]" then we execute parse_ini_file() on the newly-created
file.

Because "Characters {}|&~![()" must not be used anywhere in the key"
(dixit the manual) I'd expect an error message, or at least a Strict
notice.

Actual result:
--
PHP segfaults/crashes

(tested on 5.2.1 on WinXP and 5.1.2 on Ubuntu 6.06)

-- 
Edit bug report at http://bugs.php.net/?id=40752&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=40752&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=40752&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=40752&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40752&r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=40752&r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=40752&r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=40752&r=needscript
Try newer version:http://bugs.php.net/fix.php?id=40752&r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=40752&r=support
Expected behavior:http://bugs.php.net/fix.php?id=40752&r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=40752&r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=40752&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40752&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=40752&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40752&r=dst
IIS Stability:http://bugs.php.net/fix.php?id=40752&r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=40752&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=40752&r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=40752&r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=40752&r=mysqlcfg