#40793 [NEW]: xmlrpc_is_fault shows warning if parameter is not an array

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #40793 [NEW]: xmlrpc_is_fault shows warning if parameter is not an array

    From: camka at email dot ee
    Operating system: windows
    PHP version: 5.2.1
    PHP Bug Type: XMLRPC-EPI related
    Bug description: xmlrpc_is_fault shows warning if parameter is not an array

    Description:
    ------------
    xmlrpc_is_fault is supposed to accept a result returned by xmlrpc_decode.


    As xmlrpc_decode can return non-array value, xmlrpc_is_fault throws a
    notice:

    xmlrpc_is_fault() : Array argument expected

    which is incorrect, as it is common to simply pass the decoded xml
    response directly into is_fault() function to check, whether it has been
    fault or not.

    Reproduce code:
    ---------------
    <?
    var_dump(xmlrpc_is_fault(xmlrpc_decode('<?xml version="1.0"
    encoding="utf-8"?><methodResponse><params><param><value><int> 2</int></value></param></params></methodResponse>',
    'utf-8')));

    Expected result:
    ----------------
    bool(false)

    Actual result:
    --------------
    Notice: PHPDocument8 line 2 - xmlrpc_is_fault()
    [function.xmlrpc-is-fault]: Array argument expected

    bool(false)

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

  2. Similar Questions and Discussions

    1. #40793 [Opn->Bgs]: xmlrpc_is_fault shows warning if parameter is not an array
      ID: 40793 Updated by: tony2001@php.net Reported By: camka at email dot ee -Status: Open +Status: ...
    2. #38974 [NEW]: array should throw warning
      From: hendlerman at yahoo dot com Operating system: windows XP PHP version: 5.1.6 PHP Bug Type: Arrays related Bug...
    3. #38974 [Opn->Bgs]: array should throw warning
      ID: 38974 Updated by: derick@php.net Reported By: hendlerman at yahoo dot com -Status: Open +Status: ...
    4. #23104 [Ver->Asn]: Default array parameter value
      ID: 23104 Updated by: iliaa@php.net Reported By: mkong at intisoft dot com -Status: Verified +Status: ...
    5. Warning: Cannot use a scalar value as an array in
      Hi all This has just started coming up on a site I run. I haven't changed anything, it just started happening. Unfortunately, it's an adult...
  3. #2

    Default #40793 [Bgs->Opn]: xmlrpc_is_fault shows warning if parameter is not an array

    ID: 40793
    User updated by: camka at email dot ee
    Reported By: camka at email dot ee
    -Status: Bogus
    +Status: Open
    Bug Type: XMLRPC-EPI related
    Operating System: windows
    PHP Version: 5.2.1
    New Comment:

    Sory, but I slightly disagree.

    In current implementation I must implicitly check, if decoded xml
    response is array or not before passing it to xmlrpc_is_fault(),
    otherwise it gives me a notice. This is just unnecessary additional
    confusing check to do, which makes a code dirty and unclear. If this
    check would be inside is_fault function the implementation would be
    more incapsulated and simple for developer using xmlrpc ext.

    Or may be there is another way to check whether the response contains a
    fault or not?

    thank you


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-03-13 12:51:54] [email]tony2001@php.net[/email]

    The function is supposed to accept only arrays by design.

    ------------------------------------------------------------------------

    [2007-03-13 12:41:37] camka at email dot ee

    Description:
    ------------
    xmlrpc_is_fault is supposed to accept a result returned by
    xmlrpc_decode.

    As xmlrpc_decode can return non-array value, xmlrpc_is_fault throws a
    notice:

    xmlrpc_is_fault() : Array argument expected

    which is incorrect, as it is common to simply pass the decoded xml
    response directly into is_fault() function to check, whether it has
    been fault or not.

    Reproduce code:
    ---------------
    <?
    var_dump(xmlrpc_is_fault(xmlrpc_decode('<?xml version="1.0"
    encoding="utf-8"?><methodResponse><params><param><value><int> 2</int></value></param></params></methodResponse>',
    'utf-8')));

    Expected result:
    ----------------
    bool(false)

    Actual result:
    --------------
    Notice: PHPDocument8 line 2 - xmlrpc_is_fault()
    [function.xmlrpc-is-fault]: Array argument expected

    bool(false)


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40793&edit=1[/url]
    camka at email dot ee Guest

  4. #3

    Default #40793 [Opn->Bgs]: xmlrpc_is_fault shows warning if parameter is not an array

    ID: 40793
    Updated by: [email]tony2001@php.net[/email]
    Reported By: camka at email dot ee
    -Status: Open
    +Status: Bogus
    Bug Type: XMLRPC-EPI related
    Operating System: windows
    PHP Version: 5.2.1
    New Comment:
    >Sory, but I slightly disagree.
    It's hard to disagree with a fact.
    The function IS designed this way and is_array() check is not that
    ugly, dirty, unclear and confusing.

    Whether it was reasonable implementation or not - that's a different
    question.
    The XMLRPC extension is unmaintained for a long time and I personally
    do not feel willing enough to change it's behavior just because it
    requires one is_array() call.

    And this is definitely not a BUG, but a change request.

    Actually we have simular things in many places - for example, fread()
    and fwrite() emit a notice when invalid stream passed, even though
    fopen() might return FALSE.
    And you have to use those "unnecessary, confusing, ugly, dirty and
    unclear" checks to be sure the stream is valid.


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-03-13 13:41:04] camka at email dot ee

    Sory, but I slightly disagree.

    In current implementation I must implicitly check, if decoded xml
    response is array or not before passing it to xmlrpc_is_fault(),
    otherwise it gives me a notice. This is just unnecessary additional
    confusing check to do, which makes a code dirty and unclear. If this
    check would be inside is_fault function the implementation would be
    more incapsulated and simple for developer using xmlrpc ext.

    Or may be there is another way to check whether the response contains a
    fault or not?

    thank you

    ------------------------------------------------------------------------

    [2007-03-13 12:51:54] [email]tony2001@php.net[/email]

    The function is supposed to accept only arrays by design.

    ------------------------------------------------------------------------

    [2007-03-13 12:41:37] camka at email dot ee

    Description:
    ------------
    xmlrpc_is_fault is supposed to accept a result returned by
    xmlrpc_decode.

    As xmlrpc_decode can return non-array value, xmlrpc_is_fault throws a
    notice:

    xmlrpc_is_fault() : Array argument expected

    which is incorrect, as it is common to simply pass the decoded xml
    response directly into is_fault() function to check, whether it has
    been fault or not.

    Reproduce code:
    ---------------
    <?
    var_dump(xmlrpc_is_fault(xmlrpc_decode('<?xml version="1.0"
    encoding="utf-8"?><methodResponse><params><param><value><int> 2</int></value></param></params></methodResponse>',
    'utf-8')));

    Expected result:
    ----------------
    bool(false)

    Actual result:
    --------------
    Notice: PHPDocument8 line 2 - xmlrpc_is_fault()
    [function.xmlrpc-is-fault]: Array argument expected

    bool(false)


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40793&edit=1[/url]
    tony2001@php.net Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139