From 42291c61619d61b0111e1d33041dedfa13801c14 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Wed, 2 Feb 2011 15:02:48 +0800 Subject: [PATCH] MDL-26010 External blog synchronization removes non-relevant post records --- blog/lib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/blog/lib.php b/blog/lib.php index a8bd8f76d6fb9..0b28249a9011a 100644 --- a/blog/lib.php +++ b/blog/lib.php @@ -264,7 +264,9 @@ function blog_sync_external_entries($externalblog) { //Look at the posts we have in the database to check if any of them have been deleted from the feed. //Only checking posts within the time frame returned by the rss feed. Older items may have been deleted or //may just not be returned anymore. We cant tell the difference so we leave older posts alone. - $dbposts = $DB->get_records_select('post', 'created > :ts', array('ts' => $oldesttimestamp), '', 'id, uniquehash'); + $sql = "SELECT id, uniquehash FROM {post} WHERE ".$DB->sql_compare_text('content')." = :blogid AND module = 'blog_external' AND created > :ts"; + $dbposts = $DB->get_records_sql($sql, array('blogid' => $externalblog->id, 'ts' => $oldesttimestamp)); + $todelete = array(); foreach($dbposts as $dbpost) { if ( !in_array($dbpost->uniquehash, $uniquehashes) ) {