php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #49496 xmlrpc_is_fault() should not throw a Notice when given argument is not an array
Submitted: 2009-09-08 07:18 UTC Modified: 2021-04-13 13:54 UTC
From: torben@php.net Assigned: cmb (profile)
Status: Wont fix Package: XMLRPC-EPI related
PHP Version: 5.3SVN-2009-09-08 (SVN) OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: torben@php.net
New email:
PHP Version: OS:

 

 [2009-09-08 07:18 UTC] 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;
 	}
 



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-29 12:22 UTC] jani@php.net
-Package: Feature/Change Request +Package: XMLRPC-EPI related
 [2021-04-13 13:54 UTC] cmb@php.net
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2021-04-13 13:54 UTC] cmb@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC