From 5bd2fc5f5c132bcc38851e6712da58c3074f5212 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 28 Jul 2009 00:43:03 +0000 Subject: [PATCH] Check for the existance of the table before making queries against it. It might really have been deleted. --- docs/changelog/7.x.x.txt | 1 + docs/upgrades/upgrade_7.7.6-7.7.7.pl | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 802e4ea24..6a3340a8e 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -9,6 +9,7 @@ - fixed #10702: Product displays empty brochure, warranty, manual fields - fixed #10704: Commit version tag from AdminBar is not working - fixed #10510: Product Thumbnails overlap Controls + - fixed #10705: 7.7.2 upgrade script (sometimes) removes a table that the 7.7.7 upgrade script assumes is present 7.7.16 - fixed #10590: Session::DateTime->secondsToInterval doesn't allow 7 weeks diff --git a/docs/upgrades/upgrade_7.7.6-7.7.7.pl b/docs/upgrades/upgrade_7.7.6-7.7.7.pl index 65d97d270..e596e6ed2 100644 --- a/docs/upgrades/upgrade_7.7.6-7.7.7.pl +++ b/docs/upgrades/upgrade_7.7.6-7.7.7.pl @@ -52,14 +52,17 @@ finish($session); # this line required sub removeDanglingOldRssAssets { my $session = shift; print "\tChecking for uses of RSSCapable...\n" unless $quiet; - my @rssCapableClasses = $session->db->buildArray('SELECT className FROM RSSCapable INNER JOIN asset ON RSSCapable.assetId=asset.assetId GROUP BY className'); - if (@rssCapableClasses) { - warn "\t\tThis site is using the assets\n\t\t\t" . join(', ', @rssCapableClasses) . "\n\t\twhich use the RSSCapable class! Support RSSCapable has been dropped and it will no longer be maintained.\n"; - } - else { - print "\t\tNot used, removing leftover assets, if any.\n" unless $quiet; - $session->db->write(q|DELETE FROM assetData WHERE assetId IN (SELECT assetId FROM ASSET WHERE className="WebGUI::Asset::RssFromParent")|); - $session->db->write(q|DELETE FROM asset WHERE className = "WebGUI::Asset::RssFromParent"|); + my $peek = $session->db->dbh->table_info(undef, undef, 'RSSCapable'); + if ($peek->fetchrow_hashref()) { + my @rssCapableClasses = $session->db->buildArray('SELECT className FROM RSSCapable INNER JOIN asset ON RSSCapable.assetId=asset.assetId GROUP BY className'); + if (@rssCapableClasses) { + warn "\t\tThis site is using the assets\n\t\t\t" . join(', ', @rssCapableClasses) . "\n\t\twhich use the RSSCapable class! Support RSSCapable has been dropped and it will no longer be maintained.\n"; + } + else { + print "\t\tNot used, removing leftover assets, if any.\n" unless $quiet; + $session->db->write(q|DELETE FROM assetData WHERE assetId IN (SELECT assetId FROM ASSET WHERE className="WebGUI::Asset::RssFromParent")|); + $session->db->write(q|DELETE FROM asset WHERE className = "WebGUI::Asset::RssFromParent"|); + } } print "\tDone.\n" unless $quiet; }