From 4f85ad56e655510236769f6189134af23fd423a3 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Sat, 10 Mar 2012 16:04:32 -0800 Subject: [PATCH] Do not build a massive array of users when giving each user an address book from their profile. Instead, get one userId at a time. --- docs/upgrades/upgrade_7.10.21-7.10.22.pl | 10 ++++++---- docs/upgrades/upgrade_7.9.34-7.10.22.pl | 9 +++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/docs/upgrades/upgrade_7.10.21-7.10.22.pl b/docs/upgrades/upgrade_7.10.21-7.10.22.pl index 41f41d697..3699cd990 100644 --- a/docs/upgrades/upgrade_7.10.21-7.10.22.pl +++ b/docs/upgrades/upgrade_7.10.21-7.10.22.pl @@ -63,12 +63,14 @@ sub addLinkedProfileAddress { my $session = shift; print "\tAdding linked profile addresses for existing users... " unless $quiet; - my $users = $session->db->buildArrayRef( q{ - select userId from users where userId not in ('1','3') - } ); + my $users = $session->db->read( q{ select userId from users } ); - foreach my $userId (@$users) { + use WebGUI::User; + use WebGUI::Shop::AddressBook; + while (my ($userId) = $users->array()) { #check to see if there is user profile information available + next if $userId eq '1' or $userId eq '3'; + last unless $userId; my $u = WebGUI::User->new($session,$userId); #skip if user does not have any homeAddress fields filled in next unless ( diff --git a/docs/upgrades/upgrade_7.9.34-7.10.22.pl b/docs/upgrades/upgrade_7.9.34-7.10.22.pl index 33cb8dea8..4ede1410c 100644 --- a/docs/upgrades/upgrade_7.9.34-7.10.22.pl +++ b/docs/upgrades/upgrade_7.9.34-7.10.22.pl @@ -433,14 +433,15 @@ sub addLinkedProfileAddress { my $session = shift; print "\tAdding linked profile addresses for existing users... " unless $quiet; - my $users = $session->db->buildArrayRef( q{ - select userId from users where userId not in ('1','3') - } ); + my $users = $session->db->read( q{ select userId from users } ); use WebGUI::User; use WebGUI::Shop::AddressBook; - foreach my $userId (@$users) { + + while (my ($userId) = $users->array()) { #check to see if there is user profile information available + next if $userId eq '1' or $userId eq '3'; + last unless $userId; my $u = WebGUI::User->new($session,$userId); #skip if user does not have any homeAddress fields filled in next unless (