Is your always_populate_raw_post_data enabled? Also, have you tried
accessing the data from php://input ?
On 4-May-07, at 4:18 PM, Dirk Haun wrote:
I believe this is a bug in PHP 5.2.2. I've tried to report this for
PHP
5.2.2RC2 but apparently wasn't making myself clear or wasn't following
the proper procedures ...
Anyway, as I wrote before[1], "raw" POST data isn't making it
through in
PHP 5.2.2 which results in XML-RPC communications to fail, at least
when
using the PEAR::XML_RPC package.
Consider this little script (send.php):
--- snip ---
<?php
require_once 'XML/RPC.php';
$sourceURI = 'http://www.example.com/'; // doesn't matter here
$targetURI = $sourceURI;
$client = new XML_RPC_Client('/receive.php', $_SERVER['HTTP_HOST']);
$client->setDebug(1);
$msg = new XML_RPC_Message('pingback.ping',
array(new XML_RPC_Value($sourceURI, 'string'),
new XML_RPC_Value($targetURI, 'string')));
$response = $client->send($msg, 0, 'http');
?>
--- snip ---
This makes a simple XML-RPC call as used for Pingbacks. For the
receiving end of the communication, let's use this as receive.php:
--- snip ---
<?php
print_r(getallheaders());
echo $GLOBALS['HTTP_RAW_POST_DATA'] . "\n\n";
?>
--- snip ---
Now when I call up send.php (both located in the web root of a server
running PHP 5.2.2), I get this output:
---GOT---
HTTP/1.1 200 OK
Date: Fri, 04 May 2007 20:07:58 GMT
Server: Apache/1.3.37 (Unix) PHP/5.2.2
X-Powered-By: PHP/5.2.2
Connection: close
Content-Type: text/html
Array
(
[Content-Length] => 282
[Content-Type] => text/xml
[Host] => myhost.example.com
[User-Agent] => PEAR XML_RPC
)
<br />
<b>Notice</b>: Undefined index: HTTP_RAW_POST_DATA in <b>/usr/local/
apache/vhost/geeklog/public_html/receive.php</b> on line <b>5</
b><br />
---END---
So $GLOBALS['HTTP_RAW_POST_DATA'] is not set. The PEAR::XML_RPC
package
actually uses $HTTP_RAW_POST_DATA on the receiving end, but that
doesn't
appear to be set either. And the always_populate_raw_post_data
option in
php.ini doesn't make a difference.
Switching back to PHP 5.2.1 (same machine, same configuration) makes
everything work as expected:
---GOT---
HTTP/1.1 200 OK
Date: Fri, 04 May 2007 20:11:28 GMT
Server: Apache/1.3.37 (Unix) PHP/5.2.1
X-Powered-By: PHP/5.2.1
Connection: close
Content-Type: text/html
Array
(
[Content-Length] => 282
[Content-Type] => text/xml
[Host] => myhost.example.com
[User-Agent] => PEAR XML_RPC
)
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>pingback.ping</methodName>
<params>
<param>
<value><string>http://www.example.com/</string></value>
</param>
<param>
<value><string>http://www.example.com/</string></value>
</param>
</params>
</methodCall>
---END---
This is on a Linux box, but I have confirmation (thanks, Mike) of the
same thing happening on Windows.
Can anyone please
1) confirm this or tell me what I'm doing wrong and
2) tell me what else I should have done (other than posting here and
emailing Ilia, as the PHP 5 release manager), in case I ever run into
something similar again.
Thanks.
bye, Dirk
[1] <http://news.php.net/php.internals/29103>
--
http://www.geeklog.net/
http://geeklog.info/
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Ilia Alshanetsky
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php