Page 1 of 1
Problem with pingback
Posted: Sun Aug 12, 2007 11:21 pm
by blog.brockha.us
A WordPress blogger sent me 3 different pingbacks last week, that didn't made it into my comments database.
Now I evaulated the logfile to find out, what's happening here:
Code: Select all
"GET /index.php?/archives/97-Daitokai-in-Berlin.html HTTP/1.1" 200 19581 "-" "WordPress/2.2.1"
"POST /comment.php HTTP/1.0" 200 0 "-" "Incutio XML-RPC -- WordPress/2.2.1"
Wordpress is reading the article and evaluating the pingback url of it and then tries to send the pingback.
Looking into the html this article is producing, I found this:
Code: Select all
<link rel="pingback" href="http://blog.brockha.us/comment.php?type=pingback&entry_id=97" />
So this looks like WordPress only uses the PHP page and ignores the parameters given in this pingback link, right?
But it is even worse: Evaluating the HTML code of my article further, I found
another pingback url!
Code: Select all
<link rel="pingback" href="http://blog.brockha.us/serendipity_xmlrpc.php" />
I guess the second one is added by the XMLRPC plugin, and I think, this is the correct one? If this is the case, where is the first pingback URL coming from and is ist realy valid?
Re: Problem with pingback
Posted: Mon Aug 13, 2007 9:32 am
by garvinhicking
Hi!
The first pingback comes from the s9y source, and the second one from the xmlrpc-plugin, yes.
Sadly, even though they use the same syntax, they are required for different aspects.
The first one is the one that WP should fetch, that much is true. You don't see the ?type=...&entry_id=... variables in your log, because they seem to be converted to POST variables. You might need to setup a HTTP POST Variables logger. The comment.php has a $tb_logging variable that already loggs the data for trackbacks, you could easily do the same for 'pingbacks' as well. This might give us a clue.
Sending pingbacks are only supported since 1.3 alpha versions of serendipity, I don't know if your template even displays pingbacks. They are a whole new type ('PINGBACK' instead of 'NORMAL' or 'TRACKBACK') and some templates might not fetch this. In fact, I don't know if any template yet fetches them.
The xml-rpc plugin needs that 'pingback' rel href to be able to auto-detect XML-RPC posting mechanisms in many clients.
Regards,
Garvin
Re: Problem with pingback
Posted: Mon Aug 13, 2007 12:54 pm
by blog.brockha.us
garvinhicking wrote:The first pingback comes from the s9y source, and the second one from the xmlrpc-plugin, yes.
No, the first url comes from my template, not from the core code..
garvinhicking wrote:Sadly, even though they use the same syntax, they are required for different aspects.
The first one is the one that WP should fetch, that much is true. You don't see the ?type=...&entry_id=... variables in your log, because they seem to be converted to POST variables. You might need to setup a HTTP POST Variables logger. The comment.php has a $tb_logging variable that already loggs the data for trackbacks, you could easily do the same for 'pingbacks' as well. This might give us a clue.
Sending pingbacks are only supported since 1.3 alpha versions of serendipity, I don't know if your template even displays pingbacks. They are a whole new type ('PINGBACK' instead of 'NORMAL' or 'TRACKBACK') and some templates might not fetch this. In fact, I don't know if any template yet fetches them.
Pingback
sending from s9y is only supported since 1.3, but pingback
receiving (what I am talking about at the moment) is available much earlier, at least from 1.2 on (it's there since I know s9y).
I checked my database now and I only have TRACKBACK and NORMAL comments in it. So the pingback didn't made it into my db.
I have to check the POST params and have to log some more stuffe, in order to get the problem..
garvinhicking wrote:The xml-rpc plugin needs that 'pingback' rel href to be able to auto-detect XML-RPC posting mechanisms in many clients.

Are you sure, the XML-RPC plugin is not able to fetch the pingbacks, too? Aren't pingbacks just comments sent by XML-RPC? Hmm.. I have to check the pingback spec, I guess.
Re: Problem with pingback
Posted: Mon Aug 13, 2007 1:07 pm
by garvinhicking
Hi!
No, the first url comes from my template, not from the core code..
Sorry for the confusion, that's what I meant.
Pingback sending from s9y is only supported since 1.3, but pingback receiving (what I am talking about at the moment) is available much earlier, at least from 1.2 on (it's there since I know s9y).
Ah, okay. I've never worked with pingbacks. I find them quite irrelevant, so I've never really cared about any of this.
Are you sure, the XML-RPC plugin is not able to fetch the pingbacks, too? Aren't pingbacks just comments sent by XML-RPC? Hmm.. I have to check the pingback spec, I guess.
Hm, good question. I'm not sure, but I believe that pingbacks are not received via the XML-RPC plugin.
Regards,
Garvin
Re: Problem with pingback
Posted: Mon Aug 13, 2007 1:20 pm
by blog.brockha.us
garvinhicking wrote:Ah, okay. I've never worked with pingbacks. I find them quite irrelevant, so I've never really cared about any of this.
But this seems to be the default xBack method in WordPress.. Isn't it?
garvinhicking wrote:Hm, good question. I'm not sure, but I believe that pingbacks are not received via the XML-RPC plugin.
Okay, I will investigate that further.
Thanks for your input, Garvin!
Posted: Tue Aug 14, 2007 5:10 pm
by blog.brockha.us
I investigated the problem further. The problem is: Pingbacks are not evaluated correctly in Serendipity using the internal pingback functionality (the first link in my HTML code)! I coded a "test pingbacker" for testing the pingback functionality and all my pingbacks were rejected, because s9y didn't find (in its opinion) valid pingback XML.
The wrong code is found in functions_trackback.inc::add_pingback. The pregmatch there is wrong, as it doesn't accept line feeds and searches for <param><value/></param>, but pingback is sent (valid) as <param><name/><value/></param>.
So I changed the add_pingback function like this:
Code: Select all
/**
* Receive a pingback
*
* @access public
* @param int The entryid to receive a pingback for
* @param string The foreign postdata to add
* @return boolean
*/
function add_pingback ($id, $postdata) {
global $serendipity;
$sourceURI = getPingbackParam('sourceURI', $postdata);
$targetURI = getPingbackParam('targetURI', $postdata);
if (isset($sourceURI) && isset($targetURI)) {
$path = parse_url($sourceURI);
$local = $targetURI;
$comment['title'] = 'PingBack';
$comment['url'] = $sourceURI;
$comment['comment'] = '';
$comment['name'] = $path['host'];
serendipity_saveComment($id, $comment, 'PINGBACK');
return 1;
}
if(preg_match('@<methodCall>\s*<methodName>\s*pingback.ping\s*</methodName>\s*' . '<params>\s*<param>\s*<value>\s*<string>([^<]*)</string>\s*</value>\s*</param>\s*' . '<param>\s*<value>\s*<string>([^<]*)</string>\s*</value>\s*</param>\s*</params>\s*' . '</methodCall>@is', $postdata, $matches)) {
$remote = $matches[1];
$local = $matches[2];
$comment['title'] = '';
$comment['url'] = $remote;
$comment['comment'] = '';
$comment['name'] = '';
serendipity_saveComment($id, $comment, 'PINGBACK');
return 1;
}
return 0;
}
/**
* Gets a XML-RPC pingback.ping value by given parameter name
* @access private
* @param string Name of the paramameter
* @param string Buffer containing the pingback XML
*/
function getPingbackParam($paramName, $data)
{
$pattern = "<methodCall>.*?<methodName>\s*pingback.ping\s*</methodName>.*?<params>.*?<param>\s*" . "((<name>\s*$paramName\s*</name>\s*<value>\s*<string>([^<]*)</string>\s*</value>)|" . "(<value>\s*<string>([^<]*)</string>\s*</value>\s*<name>\s*$paramName\s*</name>))\s*" . "</param>.*?</params>.*?</methodCall>";
if (preg_match('@' . $pattern .'@is',$data, $matches)) {
return $matches[3];
} else {
return null;
}
}
(I broke the patterns to make the display nice here..)
Now Serendipity receives PingBacks, too.
Som stuff is missing:
1.) I don't fetch the page yet where the pingback is coming from. This is the only way to fill comments titel and comment while processing a pingback. I will add this soon, too.
2.) The AntiSpam plugin is not processing Pingbacks in any way. But it shoud do it in the same way as it is done with trackbacks.
3.) Serendipity is not able yet to display pingbacks! They won't be loaded by any smarty function I found. So I patched functions_smarty.inc.php::serendipity_fetchTrackbacks in that way, that it does not only load trackbacks but pingbacks, too:
Code: Select all
/**
* Fetch a list of trackbacks for an entry
*
* @access public
* @param int The ID of the entry
* @param string How many trackbacks to show
* @param boolean If true, also non-approved trackbacks will be shown
* @return
*/
function &serendipity_fetchTrackbacks($id, $limit = null, $showAll = false) {
global $serendipity;
if (!$showAll) {
$and = "AND status = 'approved'";
}
$query = "SELECT * FROM {$serendipity['dbPrefix']}comments WHERE entry_id = '". (int)$id ."' AND (type = 'TRACKBACK' OR type = 'PINGBACK') $and ORDER BY id";
if (isset($limit)) {
$limit = serendipity_db_limit_sql($limit);
$query .= " $limit";
}
$comments = serendipity_db_query($query);
if (!is_array($comments)) {
return array();
}
return $comments;
}
Now PingBacks are displayed in normal templates in the trackback section.
Posted: Wed Sep 26, 2007 8:41 pm
by johncanary
Thanks for your contribution.
I might try it out.
However, when will full pingback functionality be in the official release/patch?
Adios
Posted: Thu Sep 27, 2007 2:21 pm
by blog.brockha.us
It is already. You have to use version 1.3 (the nightly builds on the download page).
Posted: Thu Sep 27, 2007 3:16 pm
by johncanary
Thanks for the info
Posted: Thu Sep 27, 2007 9:07 pm
by chickens
blog.brockha.us wrote:It is already. You have to use version 1.3 (the nightly builds on the download page).
Are the nightly builds stable enough for the brave among us to use on a live site? I've ran a ton of nightly builds on other projects and had them bite me due to bugs in them.
I have no problem trying test builds, I just dont feel like dealing with something thats going to crash every 20 minutes. I ran the nightly versions of Firefox 3 for a while and the sucker would crash at least once an hour. I can deal with this when its just myself, I just want to put other people through the hassle with my site.
If you say it is stable enough I will upgrade my site and provide any necessary feedback.
Posted: Thu Sep 27, 2007 9:27 pm
by garvinhicking
Hi!
The new 1.3 version contains yet still very little difference to serendipity 1.2, the most central one being pingbacks.
So IMHO it's pretty safe to testdrive the 1.3 version. I myself do.
Regards,
Garvin
Posted: Fri Sep 28, 2007 3:31 am
by blog.brockha.us
I do it, too, and never ran into any stability or other problem. I think, at the moment the 1.3 is in so good condition, I would even dare to release it..
As Garvin said: At the moment the 1.3 is mainly a 1.2 with complete pingback/trackback support, not much more, that changed..
Posted: Fri Sep 28, 2007 7:22 am
by chickens
I am now running the latest SVN version. Can't see a difference, I guess that is good... nothing is broken that I can see.