php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41258 setAttributeNS has inconsistent behaviour when raising exceptions
Submitted: 2007-05-02 08:55 UTC Modified: 2007-05-02 14:50 UTC
From: daniel dot oconnor at gmail dot com Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.2.1 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: daniel dot oconnor at gmail dot com
New email:
PHP Version: OS:

 

 [2007-05-02 08:55 UTC] daniel dot oconnor at gmail dot com
Description:
------------
Inconsistent behaviour when raising exceptions. No exception is raised until line 10

Reproduce code:
---------------
<?php
$d = new DOMDocument();
$example = $d->createElementNS('http://foo.com','example');
$example->setAttributeNS('http://bar.com', 'bar:bar',"value");
$example->setAttributeNS('http://bar.com', 'monkey',"value");

$d = new DOMDocument();
$example = $d->createElementNS('http://foo.com','example');
$example->setAttributeNS('http://fish.com', 'bar:bar',"value");
$example->setAttributeNS('http://bar.com', 'monkey',"value");

Expected result:
----------------
 1. An exception raised on the second setAttributeNS (line 4)
 2. A more meaningful error than 'Namespace Error' - "No namespace prefix found for <http://fish.com>"

Actual result:
--------------
An exception on line 10

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-02 12:54 UTC] rrichards@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Line 4 is fine as namespace URI with an associated prefix already exists (it was created when from line 3). The prefix gets attached to the attribute. Error messages are not a bug, but feel free to open a feature request for more verbose messages though.
 [2007-05-02 14:50 UTC] daniel dot oconnor at gmail dot com
This is not a functionality bug, but a usability one.

Please see http://clockwerx.blogspot.com/2007/05/bogus-this.html for more detail - it expands on some of the real world use problems related to the behavior exhibited here. Take it with a grain of salt, because I've been fighting this code all day and am more than a little cranky.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 08:01:27 2024 UTC