Skip to content

Commit 4ea362b

Browse files
committedJan 19, 2012
Merge branch 'master' into WebGUI8.
2 parents e97d84f + c35b2e5 commit 4ea362b

6 files changed

+92
-185
lines changed
 

‎docs/changelog/7.x.x.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
7.10.25
2+
13
7.10.24
24
- fixed #12318: asset error causes asset manager to fail
35
- fixed #12308: error message used scalar as reference
Binary file not shown.
Binary file not shown.

‎docs/upgrades/upgrade_7.10.23-7.10.24.pl

-183
This file was deleted.

‎sbin/findBrokenAssets.pl

+90-2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ sub progress {
7474
##Guarantee that we get the most recent revisionDate
7575
my $max_revision = $session->db->prepare('select max(revisionDate) from assetData where assetId=?');
7676

77+
print "Checking all assets\n";
7778
my $count = 1;
7879
my %classTables; # Cache definition lookups
7980
while ( my %row = $sth->hash ) {
@@ -204,6 +205,80 @@ sub progress {
204205
} ## end while ( my %row = $sth->hash)
205206
$sth->finish;
206207
$max_revision->finish;
208+
print "\n";
209+
210+
my $shortcuts = $session->db->quickScalar(q!select count(*) from asset where className='WebGUI::Asset::Shortcut'!);
211+
if ($shortcuts) {
212+
print "Checking for broken shortcuts\n";
213+
my $get_shortcut = WebGUI::Asset::Shortcut->getIsa($session, 0, {returnAll => 1});
214+
$count = 0;
215+
SHORTCUT: while (1) {
216+
my $shortcut = eval { $get_shortcut->() };
217+
if ( $@ || Exception::Class->caught() ) {
218+
##Do nothing, since it would have been caught above
219+
printf "\r%-68s", "No shortcut to check";
220+
}
221+
elsif (!$shortcut) {
222+
last SHORTCUT
223+
}
224+
else {
225+
my $linked_asset = eval { WebGUI::Asset->newPending($session, $shortcut->get('shortcutToAssetId')); };
226+
if ( $@ || Exception::Class->caught() || ! $linked_asset ) {
227+
printf "\r%-68s", "-- Broken shortcut: ".$shortcut->getId.' pointing to '.$shortcut->get('shortcutToAssetId');
228+
if ($delete) {
229+
my $success = $shortcut->purge;
230+
if ($success) {
231+
print "Purged shortcut";
232+
}
233+
else {
234+
print "Could not purge shortcut";
235+
}
236+
}
237+
print "\n";
238+
}
239+
}
240+
progress( $shortcuts, $count++ ) unless $no_progress;
241+
}
242+
progress( $shortcuts, $count ) unless $no_progress;
243+
}
244+
245+
print "\n";
246+
247+
my $file_assets = $session->db->quickScalar(q!select count(*) from asset where className like 'WebGUI::Asset::File%'!);
248+
if ($file_assets) {
249+
print "Checking for broken File Assets\n";
250+
my $get_asset = WebGUI::Asset::File->getIsa($session, 0, {returnAll => 1});
251+
$count = 0;
252+
FILE_ASSET: while (1) {
253+
my $file_asset = eval { $get_asset->() };
254+
if ( $@ || Exception::Class->caught() ) {
255+
##Do nothing, since it would have been caught above
256+
printf "\r%-68s", "No asset to check";
257+
}
258+
elsif (!$file_asset) {
259+
last FILE_ASSET
260+
}
261+
else {
262+
my $storage = $file_asset->getStorageLocation;
263+
my $file = $storage->getPath($file_asset->get('filename'));
264+
if (! -e $file) {
265+
printf "\r%-s", "-- Broken file asset: ".$file_asset->getId." file does not exist: $file";
266+
if ($delete) {
267+
my $success = $file_asset->purge;
268+
if ($success) {
269+
print "Purged File Asset";
270+
}
271+
else {
272+
print "Could not purge File Asset";
273+
}
274+
}
275+
print "\n";
276+
}
277+
}
278+
progress( $file_assets, $count++ ) unless $no_progress;
279+
}
280+
progress( $file_assets, $count ) unless $no_progress;
281+
}
207282

208283
finish($session);
209284
print "\n";
@@ -261,7 +336,20 @@ =head1 SYNOPSIS
261336
=head1 DESCRIPTION
262337
263338
This utility will find any broken assets that cannot be instantiated and are
264-
causing undesired operation of your website.
339+
causing undesired operation of your website. It also checks for these kinds of
340+
semi-working assets and reports them:
341+
342+
=over 4
343+
344+
=item *
345+
346+
Shortcuts pointing to assets that don't exist.
347+
348+
=item *
349+
350+
File assets that have lost their files in the uploads area.
351+
352+
=back
265353
266354
It can also automatically delete them or fix them so you can restore missing data.
267355
@@ -283,7 +371,7 @@ =head1 OPTIONS
283371
284372
=item B<--fix>
285373
286-
Try to fix any corrupted assets.
374+
Try to fix any corrupted assets. The broken Shortcuts and File Assets cannot be fixed.
287375
288376
=item B<--help>
289377

0 commit comments

Comments
 (0)
Please sign in to comment.