When a user is deleted, delete any address books as well. Uses the API to get the
Addresses, too. With tests and upgrade script to take care of old address books.
This commit is contained in:
parent
9702ffcaac
commit
61832b62b9
4 changed files with 60 additions and 15 deletions
|
|
@ -15,6 +15,7 @@
|
|||
- fixed #10449: Undefined template
|
||||
- fixed #10365: Head tags do not work "Use Packed Head Tags".
|
||||
- fixed #9927: Survey - verbatim
|
||||
- fixed #10352: Deleting a user does not clean up any address books
|
||||
|
||||
7.7.8
|
||||
- fixed: Basic Auth doesn't work if password contains colon (Arjan Widlak,
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ use Getopt::Long;
|
|||
use WebGUI::Session;
|
||||
use WebGUI::Storage;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Shop::AddressBook;
|
||||
|
||||
|
||||
my $toVersion = '7.7.9';
|
||||
|
|
@ -32,6 +33,7 @@ my $session = start(); # this line required
|
|||
|
||||
# upgrade functions go here
|
||||
repackTemplates( $session );
|
||||
deleteUnattachedAddressBooks( $session );
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
|
|
@ -86,6 +88,21 @@ sub repackTemplates {
|
|||
print "\n\t... DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Delete all AddressBooks where the userId does not exist in the users table
|
||||
sub deleteUnattachedAddressBooks {
|
||||
my $session = shift;
|
||||
|
||||
print "\n\t\tDelete all AddressBooks if the user for that book was deleted..." unless $quiet;
|
||||
my $sth = $session->db->read( "SELECT addressBookId FROM addressBook where userId NOT IN (SELECT userId FROM users)" );
|
||||
while ( my ($addressBookId) = $sth->array ) {
|
||||
my $book = WebGUI::Shop::AddressBook->new($session, $addressBookId);
|
||||
$book->delete;
|
||||
}
|
||||
|
||||
print "\n\t... DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
|
||||
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue