Check for the existance of the table before making queries against it.

It might really have been deleted.
This commit is contained in:
Colin Kuskie 2009-07-28 00:43:03 +00:00
parent 78b53aecc7
commit 5bd2fc5f5c
2 changed files with 12 additions and 8 deletions

View file

@ -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

View file

@ -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;
}