Linkback Plugin: check result properly so failures are not reported as a success in the log. Also logs (debug only) when an attempt is being made

This commit is contained in:
CiaranG 2009-09-08 13:25:59 +01:00
parent afe1b8ec3d
commit 52a197b235

View File

@ -75,6 +75,8 @@ class LinkbackPlugin extends Plugin
function linkbackUrl($url) function linkbackUrl($url)
{ {
common_log(LOG_DEBUG,"Attempting linkback for " . $url);
$orig = $url; $orig = $url;
$url = htmlspecialchars_decode($orig); $url = htmlspecialchars_decode($orig);
$scheme = parse_url($url, PHP_URL_SCHEME); $scheme = parse_url($url, PHP_URL_SCHEME);
@ -134,15 +136,20 @@ class LinkbackPlugin extends Plugin
"User-Agent: " . $this->userAgent(), "User-Agent: " . $this->userAgent(),
'content' => $request))); 'content' => $request)));
$file = file_get_contents($endpoint, false, $context); $file = file_get_contents($endpoint, false, $context);
$response = xmlrpc_decode($file); if (!$file) {
if (xmlrpc_is_fault($response)) {
common_log(LOG_WARNING, common_log(LOG_WARNING,
"Pingback request failed for '$url' ($endpoint)");
} else {
$response = xmlrpc_decode($file);
if (xmlrpc_is_fault($response)) {
common_log(LOG_WARNING,
"Pingback error for '$url' ($endpoint): ". "Pingback error for '$url' ($endpoint): ".
"$response[faultString] ($response[faultCode])"); "$response[faultString] ($response[faultCode])");
} else { } else {
common_log(LOG_INFO, common_log(LOG_INFO,
"Pingback success for '$url' ($endpoint): ". "Pingback success for '$url' ($endpoint): ".
"'$response'"); "'$response'");
}
} }
} }