php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #34278 xml_parser_get_option manual fails to specify options causing E_WARNING
Submitted: 2005-08-27 11:13 UTC Modified: 2005-08-30 09:58 UTC
From: gk at proliberty dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
 [2005-08-27 11:13 UTC] gk at proliberty dot com
Description:
------------
The documentation says, that options for xml_parser_get_option are defined in  xml_parser_set_option - i.e., none of these options are 'unsupported'.

However, E_WARNING errors are generated by passing 'unsupported' options to xml_parser_get_option.

E_WARNING indicates a serious problem (in my case, I always use a custom error handler that elevates E_WARNING errors to E_USER_ERROR (fatal) status).

Furthermore, I argue, xml_parser_get_option SHOULD INDEED support ALL options that xml_parser_set_option supports since code should be able to query the environment in which it runs.

Also, for the sake of consistency with other set/get functions, these two functions should support the same options.

SEE RELATED BUG:
Bug #12261	xml_parser_get_option doesn't get all option that xml_parser_set_option can set
http://bugs.php.net/bug.php?id=12261

Reproduce code:
---------------
<?php
$parser = xml_parser_create();
echo "XML_OPTION_CASE_FOLDING=".xml_parser_get_option ($parser,XML_OPTION_CASE_FOLDING)."\n<br>";
echo "XML_OPTION_TARGET_ENCODING=".xml_parser_get_option ($parser,XML_OPTION_TARGET_ENCODING)."\n<br>";
echo "XML_OPTION_SKIP_TAGSTART=".xml_parser_get_option ($parser,XML_OPTION_SKIP_TAGSTART)."\n<br>";
echo "XML_OPTION_SKIP_WHITE=".xml_parser_get_option ($parser,XML_OPTION_SKIP_WHITE)."\n<br>";
?>

Expected result:
----------------
XML_OPTION_CASE_FOLDING=1 
XML_OPTION_TARGET_ENCODING=UTF-8 
XML_OPTION_SKIP_TAGSTART=<current value>
XML_OPTION_SKIP_WHITE=<current value>

Actual result:
--------------
XML_OPTION_CASE_FOLDING=1 
XML_OPTION_TARGET_ENCODING=UTF-8 

Warning: xml_parser_get_option() [function.xml-parser-get-option]: Unknown option in /usr/local/apache/htdocs/test/test.php on line 5
XML_OPTION_SKIP_TAGSTART= 

Warning: xml_parser_get_option() [function.xml-parser-get-option]: Unknown option in /usr/local/apache/htdocs/test/test.php on line 6
XML_OPTION_SKIP_WHITE=

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-29 17:22 UTC] vrana@php.net
Status of this bug will be tracked under bug #12261.
 [2005-08-30 08:46 UTC] gk at proliberty dot com
I apologize for reopening this bug but it appears that bug #12261 was closed prematurely and I was not able to add a comment or re-open that bug since I am not the original author.

vrana@php.net did not indicate which functions would be corrected.

I see only this change for xml_parser_get_option, which is not sufficient:
>This function returns FALSE if parser does not refer to a valid parser or if option isn't valid (generates also a E_WARNING). Else the option's value is returned. 

>See xml_parser_set_option() for the list of options.

The problem remains that there is NO indication anywhere that any of the options in xml_parser_set_option are 'invalid' options for xml_parser_get_option.

It is not enough to say "see xml_parser_set_option()..." without updating that documentation to explain which options are only valid for one function and not for the other.

A much better solution, in my opinion, would to simply update xml_parser_get_option() to explain which options it supports rather than requiring that xml_parser_set_option() documentation describe 'invalid' options for another function: each function's documentation should focus clearly focus on its own domain.
 [2005-08-30 09:58 UTC] vrana@php.net
It's already documented in CVS, take a look at http://cvs.php.net/co.php/phpdoc/en/reference/xml/functions/xml-parser-get-option.xml
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 12:01:29 2024 UTC