mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-25227 glossary - fix delete_instance() and clean orphaned entries
This commit is contained in:
parent
f3cc571af2
commit
3b953472ac
3 changed files with 12 additions and 1 deletions
|
@ -299,6 +299,16 @@ function xmldb_glossary_upgrade($oldversion) {
|
||||||
upgrade_mod_savepoint(true, 2010042800, 'glossary');
|
upgrade_mod_savepoint(true, 2010042800, 'glossary');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($oldversion < 2010111500) {
|
||||||
|
// Delete orphaned glossary_entries not belonging to any glossary (MDL-25227)
|
||||||
|
$sql = "DELETE FROM {glossary_entries}
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT 'x' FROM {glossary} g
|
||||||
|
WHERE g.id = glossaryid)";
|
||||||
|
$DB->execute($sql);
|
||||||
|
|
||||||
|
upgrade_mod_savepoint(true, 2010111500, 'glossary');
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -194,6 +194,7 @@ function glossary_delete_instance($id) {
|
||||||
$category_select = "SELECT id FROM {glossary_categories} WHERE glossaryid = ?";
|
$category_select = "SELECT id FROM {glossary_categories} WHERE glossaryid = ?";
|
||||||
$DB->delete_records_select('glossary_entries_categories', "categoryid IN ($category_select)", array($id));
|
$DB->delete_records_select('glossary_entries_categories', "categoryid IN ($category_select)", array($id));
|
||||||
$DB->delete_records('glossary_categories', array('glossaryid'=>$id));
|
$DB->delete_records('glossary_categories', array('glossaryid'=>$id));
|
||||||
|
$DB->delete_records('glossary_entries', array('glossaryid'=>$id));
|
||||||
|
|
||||||
// delete all files
|
// delete all files
|
||||||
$fs->delete_area_files($context->id);
|
$fs->delete_area_files($context->id);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
|
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
$module->version = 2010080300;
|
$module->version = 2010111500;
|
||||||
$module->requires = 2010080300; // Requires this Moodle version
|
$module->requires = 2010080300; // Requires this Moodle version
|
||||||
$module->cron = 0; // Period for cron to check this module (secs)
|
$module->cron = 0; // Period for cron to check this module (secs)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue