Skip to content

Commit

Permalink
Merge branch 'MOODLE_39_MDL-69848' of https://github.com/golenkovm/mo…
Browse files Browse the repository at this point in the history
…odle into MOODLE_39_STABLE
  • Loading branch information
snake committed Oct 14, 2020
2 parents 3d41104 + 99d0308 commit 31d3a65
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion message/output/popup/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,22 @@ function xmldb_message_popup_upgrade($oldversion) {

if ($oldversion < 2020020600) {
// Clean up orphaned popup notification records.
$DB->delete_records_select('message_popup_notifications', 'notificationid NOT IN (SELECT id FROM {notifications})');
$fromsql = "FROM {message_popup_notifications} mpn
LEFT JOIN {notifications} n
ON mpn.notificationid = n.id
WHERE n.id IS NULL";
$total = $DB->count_records_sql("SELECT COUNT(mpn.id) " . $fromsql);
$i = 0;
$pbar = new progress_bar('deletepopupnotification', 500, true);
do {
if ($popupnotifications = $DB->get_records_sql("SELECT mpn.id " . $fromsql, null, 0, 1000)) {
list($insql, $inparams) = $DB->get_in_or_equal(array_keys($popupnotifications));
$DB->delete_records_select('message_popup_notifications', "id $insql", $inparams);
// Update progress.
$i += count($inparams);
$pbar->update($i, $total, "Cleaning up orphaned popup notification records - $i/$total.");
}
} while ($popupnotifications);

// Reportbuilder savepoint reached.
upgrade_plugin_savepoint(true, 2020020600, 'message', 'popup');
Expand Down

0 comments on commit 31d3a65

Please sign in to comment.