From: garvinhicking Date: Tue, 10 Apr 2007 13:45:54 +0000 (+0000) Subject: Fix tracbkacks. Once again. Hopefully now all cases are handled ;) X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=ef1a0bf3843477fa049feb3d0a697fb47c937c85;p=s9y.git Fix tracbkacks. Once again. Hopefully now all cases are handled ;) --- diff --git a/include/functions_trackbacks.inc.php b/include/functions_trackbacks.inc.php index ae36c60..5001421 100644 --- a/include/functions_trackbacks.inc.php +++ b/include/functions_trackbacks.inc.php @@ -421,6 +421,7 @@ FAILURE; function serendipity_handle_references($id, $author, $title, $text, $dry_run = false) { global $serendipity; static $old_references = array(); + static $saved_references = array(); static $debug = false; if ($dry_run) { @@ -430,7 +431,7 @@ function serendipity_handle_references($id, $author, $title, $text, $dry_run = f $current_references = array(); foreach($old_references AS $idx => $old_reference) { // We need the current reference ID to restore it later. - $current_references[$old_reference['link']] = $old_reference; + $saved_references[$old_reference['link']] = $current_references[$old_reference['link']] = $old_reference; } } if ($debug) echo "Got references in dry run:
" . print_r($current_references, true) . "

\n"; @@ -469,11 +470,13 @@ function serendipity_handle_references($id, $author, $title, $text, $dry_run = f $checked_locations = array(); serendipity_plugin_api::hook_event('backend_trackbacks', $locations); for ($i = 0, $j = count($locations); $i < $j; ++$i) { + if ($debug) echo "Checking {$locations[$i]}...
\n"; if ($locations[$i][0] == '/') { $locations[$i] = 'http' . (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off' ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $locations[$i]; } if (isset($checked_locations[$locations[$i]])) { + if ($debug) echo "Already checked.
\n"; continue; } @@ -493,15 +496,21 @@ function serendipity_handle_references($id, $author, $title, $text, $dry_run = f AND type = ''"; $row = serendipity_db_query($query, true, 'num'); - if ($row[0] > 0) { + if ($row[0] > 0 && isset($saved_references[$locations[$i]])) { + if ($debug) echo "Found references for $id, skipping rest
\n"; continue; } if (!isset($serendipity['noautodiscovery']) || !$serendipity['noautodiscovery']) { if (!$dry_run) { + if ($debug) echo "Enabling autodiscovery.
\n"; serendipity_reference_autodiscover($locations[$i], $url, $author, $title, serendipity_trackback_excerpt($text)); + } elseif ($debug) { + echo "Skipping autodiscovery
\n"; } $checked_locations[$locations[$i]] = true; // Store trackbacked link so that no further trackbacks will be sent to the same link + } elseif ($debug) { + echo "Skipping full autodiscovery
\n"; } } serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}references WHERE entry_id=" . (int)$id . " AND type = ''");