Browse files

MDL-26504 blog: added upgrade code to remove orphan external blog posts

Conflicts:
	lib/db/upgrade.php
	version.php

Conflicts:
	version.php
  • Loading branch information...
1 parent 89ce191 commit 63fbf99e07f8b74bfeea047dee110cd860554abc @andyjdavis andyjdavis committed with nebgor Aug 28, 2012
Showing with 11 additions and 1 deletion.
  1. +10 −0 lib/db/upgrade.php
  2. +1 −1 version.php
View
10 lib/db/upgrade.php
@@ -7149,5 +7149,15 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2011120504.05);
}
+ if ($oldversion < 2011120504.11) {
+ $subquery = 'SELECT b.id FROM {blog_external} b where ' . $DB->sql_compare_text('b.id') . ' = ' . $DB->sql_compare_text('{post}.content');
+ $sql = 'DELETE FROM {post}
+ WHERE {post}.module = \'blog_external\'
+ AND NOT EXISTS (' . $subquery . ')
+ AND ' . $DB->sql_isnotempty('post', 'uniquehash', false, false);
+ $DB->execute($sql);
+ upgrade_main_savepoint(true, 2011120504.11);
+ }
+
return true;
}
View
2 version.php
@@ -30,7 +30,7 @@
defined('MOODLE_INTERNAL') || die();
-$version = 2011120504.10; // 20111205 = branching date YYYYMMDD - do not modify!
+$version = 2011120504.11; // 20111205 = branching date YYYYMMDD - do not modify!
// RR = release increments - 00 in DEV branches
// .XX = incremental changes

0 comments on commit 63fbf99

Please sign in to comment.