diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index a6fdae070..5f7802238 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,5 +1,6 @@ 7.10.3 - fixed #11903: Unnecessary debug in Thingy + - fixed #11908: Inbox messages linger after deleting a user 7.10.2 - fixed #11884: Editing Templates impossible / Code editor not loaded diff --git a/docs/upgrades/upgrade_7.10.1-7.10.2.pl b/docs/upgrades/upgrade_7.10.1-7.10.2.pl index d2f49d9fc..92698a6a4 100644 --- a/docs/upgrades/upgrade_7.10.1-7.10.2.pl +++ b/docs/upgrades/upgrade_7.10.1-7.10.2.pl @@ -22,6 +22,7 @@ use Getopt::Long; use WebGUI::Session; use WebGUI::Storage; use WebGUI::Asset; +use WebGUI::Inbox; my $toVersion = '7.10.2'; diff --git a/docs/upgrades/upgrade_7.10.2-7.10.3.pl b/docs/upgrades/upgrade_7.10.2-7.10.3.pl index f0d799e25..e91620252 100644 --- a/docs/upgrades/upgrade_7.10.2-7.10.3.pl +++ b/docs/upgrades/upgrade_7.10.2-7.10.3.pl @@ -31,18 +31,33 @@ my $quiet; # this line required my $session = start(); # this line required # upgrade functions go here +pruneInboxMessagesFromDeletedUsers($session); finish($session); # this line required #---------------------------------------------------------------------------- # Describe what our function does -#sub exampleFunction { -# my $session = shift; -# print "\tWe're doing some stuff here that you should know about... " unless $quiet; -# # and here's our code -# print "DONE!\n" unless $quiet; -#} +sub pruneInboxMessagesFromDeletedUsers { + my $session = shift; + print "\tPruning inbox messages from deleted users. This may take a while... " unless $quiet; + my $sth = $session->db->prepare(<execute([]); + my $inbox = WebGUI::Inbox->new($session); + while (my ($messageId, $userId) = $sth->array) { + my $message = $inbox->getMessage($messageId, $userId); + if ($message) { + $message->delete; + } + } + print "...DONE!\n" unless $quiet; +} # -------------- DO NOT EDIT BELOW THIS LINE --------------------------------