@@ -74,6 +74,7 @@ sub progress {
74
74
# #Guarantee that we get the most recent revisionDate
75
75
my $max_revision = $session -> db-> prepare(' select max(revisionDate) from assetData where assetId=?' );
76
76
77
+ print " Checking all assets\n " ;
77
78
my $count = 1;
78
79
my %classTables ; # Cache definition lookups
79
80
while ( my %row = $sth -> hash ) {
@@ -204,6 +205,42 @@ sub progress {
204
205
} # # end while ( my %row = $sth->hash)
205
206
$sth -> finish;
206
207
$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 ($fix || $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
+ }
207
244
208
245
finish($session );
209
246
print " \n " ;
0 commit comments