Skip to content

Commit

Permalink
MDL-35265 - blog - Update code for removing orphaned blog association…
Browse files Browse the repository at this point in the history
… data.
  • Loading branch information
abgreeve committed Oct 8, 2012
1 parent ccd90e7 commit c0a0592
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions lib/db/upgrade.php
Expand Up @@ -1244,5 +1244,21 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2012092600.00);
}

if ($oldversion < 2012100500.01) {
// Find all orphaned blog associations that might exist.
$sql = "SELECT ba.id
FROM {blog_association} ba
LEFT JOIN {post} p
ON p.id = ba.blogid
WHERE p.id IS NULL";
$orphanedrecordids = $DB->get_records_sql($sql);
// Now delete these associations.
foreach ($orphanedrecordids as $orphanedrecord) {
$DB->delete_records('blog_association', array('id' => $orphanedrecord->id));
}

upgrade_main_savepoint(true, 2012100500.01);
}

return true;
}
2 changes: 1 addition & 1 deletion version.php
Expand Up @@ -30,7 +30,7 @@
defined('MOODLE_INTERNAL') || die();


$version = 2012100500.00; // YYYYMMDD = weekly release date of this DEV branch
$version = 2012100500.01; // YYYYMMDD = weekly release date of this DEV branch
// RR = release increments - 00 in DEV branches
// .XX = incremental changes

Expand Down

0 comments on commit c0a0592

Please sign in to comment.