php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17732 decode_request - reference vars depracated
Submitted: 2002-06-12 17:50 UTC Modified: 2003-06-25 13:06 UTC
From: ramses0 at yahoo dot com Assigned:
Status: Closed Package: XMLRPC-EPI related
PHP Version: 4.1.2 OS: Linux
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: ramses0 at yahoo dot com
New email:
PHP Version: OS:

 

 [2002-06-12 17:50 UTC] ramses0 at yahoo dot com
Using the following demonstration RPC request, the
function xmlrpc_decode_request (apparently) does not
correctly update the passed in parameter $method_name,
as described in the documentation on:
http://xmlrpc-epi.sourceforge.net/main.php?t=php_api

On a hunch, I tried changing the call to:   
  xmlrpc_decode_request($xml, &$method); 
to use call-time pass by reference. It then worked, 
but call time pass by reference is depracated:

Warning: Call-time pass-by-reference has been
deprecated - argument passed by value; If you would
like to pass it by reference, modify the declaration of
xmlrpc_decode_request(). If you would like to enable
call-time pass-by-reference, you can set
allow_call_time_pass_reference to true in your INI
file. However, future versions may not support this any
longer.

As an aside- it appears that you cannot "swallow" the warning by doing an $results = @decode( $a, &$b )... 
it stil gives the "warning, depracated" message.  So
that is possibly another bug.  I have grepped through
the source trees somewhat, but couldn't find much examples
of functions directly affecting their passed in values 
(except "sort", which is pretty complicated).

Thanks-

--Robert
(bugreport is mirrored at the sf.net pages, but that
 area appears to be mildly unmaintained)
 

<?php
$request = <<< END
<?xml version="1.0"?>
<methodCall>
<methodName>greeting</methodName>
<params>
<param>
<value><string>Dan</string></value>
</param>
</params>
</methodCall>
END;
// <?
/* ** DEBUGGING INFORMATION ** */
echo "<pre>";
echo "<b>Request:</b><br>";
print_r( $request );

// decode the request
$method_name = '';
$stuff = xmlrpc_decode_request( $request, $method_name );

echo "<b>Results:</b><br>";
print_r( $stuff );

echo "<b>Method:</b><br>";
print_r( $method_name );
echo "</pre>";
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-15 22:24 UTC] sniper@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.


 [2003-06-25 12:44 UTC] scott at executebusiness dot com
Can someone suggest why this is deprecated? I haven't found any reason for allow_call_time_pass_reference deprecation. Far as I can tell using byref is a good idea in programming to save cpu time when passing large vars.
 [2003-06-25 13:06 UTC] ramses0 at yahoo dot com
Consider the function (please forgive the incorrect math):

  function convert( $num ) {
    $num = $num + 32;
    $num = $num * (5/9);
    return( $num );
  }

What is expected behaviour of this:
  $n = 10;
  $z = convert( $n );
  print "$n, $z";

...or:
  $n = 10;
  $z = convert( &$n );
  print "$n, $z";

...should they print the same thing?  The second is "call time pass by reference".

And FYI: As I have been told, PHP uses "copy on write, pass by reference" by default anyway.

So, if you have this example scenario:
  $shakespeare = "To be or not to be, etc, etc, etc, etc";
  spellcheck( $shakespeare );

...then the function shakespeare only makes a copy of that big long string if it makes a modification.  Example:
  function spellcheck( $text ) {
    if( strstr( $text, "teh" ) ) { return FALSE; }
    return TRUE;
  }
...this function should not make that huge copy (php is magic).   This one would:
  function spellcheck( $text ) {
    $text[0] = "!";
    if( strstr( $text, "teh" ) ) { return FALSE; }
    return TRUE;
  }
...because PHP needs to keep track that the string has been modified.  Ask on the mailing lists if you really care (php-user, probably).  :^)
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Jan 20 23:01:25 2020 UTC