Req #49496 [Opn->Wfx]: xmlrpc_is_fault() should not throw a Notice when given argument is not an array
| From: | cmb@php.net | Date: | Tue, 13 Apr 2021 13:54:29 +0000 |
| Subject: | Req #49496 [Opn->Wfx]: xmlrpc_is_fault() should not throw a Notice when given argument is not an array | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-233397@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=49496&edit=1
ID: 49496
Updated by: cmb@php.net
Reported by: torben@php.net
Summary: xmlrpc_is_fault() should not throw a Notice when
given argument is not an array
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: XMLRPC-EPI related
Operating System: *
PHP Version: 5.3SVN-2009-09-08 (SVN)
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
The xmlrpc extension is unbundled and moved to PECL as of PHP
7.4.0. I'm temporarily maintaining the extension, but I will not
do any feature additions. Actually, everybody is likely better
off to switch to something else. Thus, I'm closing this ticket.
Previous Comments:
------------------------------------------------------------------------
[2009-09-08 07:18:51] torben@php.net
Description:
------------
In bug #40793 and doc bug #49378 it is reported that xmlrpc_is_fault() throws a Notice when the
passed argument is not an array. In the comments for #40793 tony2001@php.net states that this is by
design, and indeed it appears to be, but that would seem to be a broken design. xmlrpc_is_fault()
should simply return true if the passed argument represents an xmlrpc fault, and false otherwise.
Patch for PHP 5.2:
Index: ext/xmlrpc/xmlrpc-epi-php.c
===================================================================
--- ext/xmlrpc/xmlrpc-epi-php.c (revision 287478)
+++ ext/xmlrpc/xmlrpc-epi-php.c (working copy)
@@ -1445,7 +1445,7 @@
/* }}} */
/* {{{ proto bool xmlrpc_is_fault(array)
- Determines if an array value represents an XMLRPC fault. */
+ Determines if the passed value represents an XMLRPC fault. */
PHP_FUNCTION(xmlrpc_is_fault)
{
zval **arg, **val;
@@ -1455,20 +1455,20 @@
}
if (Z_TYPE_PP(arg) != IS_ARRAY) {
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array argument expected");
- } else {
- /* The "correct" way to do this would be to call the xmlrpc
- * library XMLRPC_ValueIsFault() func. However, doing that
- * would require us to create an xmlrpc value from the php
- * array, which is rather expensive, especially if it was
- * a big array. Thus, we resort to this not so clever hackery.
- */
- if (zend_hash_find(Z_ARRVAL_PP(arg), FAULT_CODE, FAULT_CODE_LEN + 1, (void**) &val) ==
SUCCESS &&
- zend_hash_find(Z_ARRVAL_PP(arg), FAULT_STRING, FAULT_STRING_LEN + 1, (void**) &val) ==
SUCCESS) {
- RETURN_TRUE;
- }
+ RETURN_FALSE;
}
+ /* The "correct" way to do this would be to call the xmlrpc
+ * library XMLRPC_ValueIsFault() func. However, doing that
+ * would require us to create an xmlrpc value from the php
+ * array, which is rather expensive, especially if it was
+ * a big array. Thus, we resort to this not so clever hackery.
+ */
+ if (zend_hash_find(Z_ARRVAL_PP(arg), FAULT_CODE, FAULT_CODE_LEN + 1, (void**) &val) == SUCCESS
&&
+ zend_hash_find(Z_ARRVAL_PP(arg), FAULT_STRING, FAULT_STRING_LEN + 1, (void**) &val) ==
SUCCESS) {
+ RETURN_TRUE;
+ }
+
RETURN_FALSE;
}
/* }}} */
Patch for PHP 5.3:
Index: ext/xmlrpc/xmlrpc-epi-php.c
===================================================================
--- ext/xmlrpc/xmlrpc-epi-php.c (revision 287473)
+++ ext/xmlrpc/xmlrpc-epi-php.c (working copy)
@@ -1495,20 +1495,24 @@
Determines if an array value represents an XMLRPC fault. */
PHP_FUNCTION(xmlrpc_is_fault)
{
- zval *arg, **val;
+ zval **arg, **val;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &arg) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &arg) == FAILURE) {
return;
}
+ if (Z_TYPE_PP(arg) != IS_ARRAY) {
+ RETURN_FALSE;
+ }
+
/* The "correct" way to do this would be to call the xmlrpc
* library XMLRPC_ValueIsFault() func. However, doing that
* would require us to create an xmlrpc value from the php
* array, which is rather expensive, especially if it was
* a big array. Thus, we resort to this not so clever hackery.
*/
- if (zend_hash_find(Z_ARRVAL_P(arg), FAULT_CODE, FAULT_CODE_LEN + 1, (void**) &val) == SUCCESS
&&
- zend_hash_find(Z_ARRVAL_P(arg), FAULT_STRING, FAULT_STRING_LEN + 1, (void**) &val) ==
SUCCESS) {
+ if (zend_hash_find(Z_ARRVAL_PP(arg), FAULT_CODE, FAULT_CODE_LEN + 1, (void**) &val) == SUCCESS
&&
+ zend_hash_find(Z_ARRVAL_PP(arg), FAULT_STRING, FAULT_STRING_LEN + 1, (void**) &val) ==
SUCCESS) {
RETURN_TRUE;
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=49496&edit=1