From 2c75ab27e6db24187f2caa65dfe5c8dc36db2a24 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Tue, 1 Jun 2010 16:22:42 -0500 Subject: [PATCH] migrate to getLineageIterator to save memory --- lib/WebGUI/Asset/Event.pm | 54 ++-- lib/WebGUI/Asset/Post.pm | 11 +- lib/WebGUI/Asset/Post/Thread.pm | 2 +- lib/WebGUI/Asset/Sku/ThingyRecord.pm | 10 +- lib/WebGUI/Asset/Wobject/Collaboration.pm | 39 ++- lib/WebGUI/Asset/Wobject/Dashboard.pm | 25 +- .../Asset/Wobject/EventManagementSystem.pm | 9 +- lib/WebGUI/Asset/Wobject/Folder.pm | 25 +- lib/WebGUI/Asset/Wobject/Gallery.pm | 18 +- lib/WebGUI/Asset/Wobject/Layout.pm | 36 ++- lib/WebGUI/Asset/Wobject/Matrix.pm | 55 ++-- lib/WebGUI/Asset/Wobject/MessageBoard.pm | 11 +- lib/WebGUI/Asset/Wobject/Navigation.pm | 32 ++- lib/WebGUI/Asset/Wobject/Shelf.pm | 10 +- lib/WebGUI/Asset/Wobject/StoryArchive.pm | 11 +- lib/WebGUI/Asset/Wobject/WikiMaster.pm | 25 +- lib/WebGUI/AssetBranch.pm | 24 +- lib/WebGUI/AssetClipboard.pm | 23 +- lib/WebGUI/AssetExportHtml.pm | 14 +- lib/WebGUI/AssetLineage.pm | 77 ++++- lib/WebGUI/AssetPackage.pm | 3 +- lib/WebGUI/AssetTrash.pm | 24 +- lib/WebGUI/Content/AssetManager.pm | 15 +- lib/WebGUI/Content/SiteIndex.pm | 1 - lib/WebGUI/Form/Asset.pm | 22 +- lib/WebGUI/Form/HTMLArea.pm | 37 ++- lib/WebGUI/Form/SelectRichEditor.pm | 14 +- lib/WebGUI/Wizard/HomePage.pm | 12 +- lib/WebGUI/Wizard/Setup.pm | 10 +- .../Workflow/Activity/ArchiveOldStories.pm | 27 +- .../Workflow/Activity/CleanTempStorage.pm | 16 +- .../Activity/CleanupEMSSubmissions.pm | 22 +- .../Workflow/Activity/ProcessEMSApprovals.pm | 2 +- sbin/findBrokenAssets.pl | 265 ++++++++++++++++++ 34 files changed, 794 insertions(+), 187 deletions(-) create mode 100644 sbin/findBrokenAssets.pl diff --git a/lib/WebGUI/Asset/Event.pm b/lib/WebGUI/Asset/Event.pm index 40856d9f5..1c929b1b6 100644 --- a/lib/WebGUI/Asset/Event.pm +++ b/lib/WebGUI/Asset/Event.pm @@ -579,8 +579,7 @@ sub getEventNext { 'assetData.assetId', ); - my $events = $self->getLineage(['siblings'], { - #returnObjects => 1, + my $events = $self->getLineageIterator(['siblings'], { includeOnlyClasses => ['WebGUI::Asset::Event'], joinClass => 'WebGUI::Asset::Event', orderByClause => join(",", @orderByColumns), @@ -588,9 +587,12 @@ sub getEventNext { limit => 1, }); - - return undef unless $events->[0]; - return WebGUI::Asset->newByDynamicClass($self->session,$events->[0]); + my $nextEvent; + eval { $nextEvent = $events->() }; + if ( WebGUI::Error->caught('WebGUI::Error::ObjecNotFound') ) { + return undef; # Normal error + } + return $nextEvent; } @@ -636,8 +638,7 @@ sub getEventPrev { 'assetData.assetId DESC', ); - my $events = $self->getLineage(['siblings'], { - #returnObjects => 1, + my $events = $self->getLineageIterator(['siblings'], { includeOnlyClasses => ['WebGUI::Asset::Event'], joinClass => 'WebGUI::Asset::Event', orderByClause => join(",",@orderByColumns), @@ -645,8 +646,12 @@ sub getEventPrev { limit => 1, }); - return undef unless $events->[0]; - return WebGUI::Asset->newByDynamicClass($self->session,$events->[0]); + my $prevEvent; + eval { $prevEvent = $events->() }; + if ( WebGUI::Error->caught( 'WebGUI::Error::ObjectNotFound' ) ) { + return undef; # Normal error + } + return $prevEvent; } @@ -1483,35 +1488,46 @@ sub processPropertiesFromFormPost { # Delete old events if ($old_id) { - my $events = $self->getLineage(["siblings"], { - returnObjects => 1, + my $events = $self->getLineageIterator(["siblings"], { includeOnlyClasses => ['WebGUI::Asset::Event'], joinClass => 'WebGUI::Asset::Event', whereClause => qq{Event.recurId = "$old_id"}, }); - $_->purge for @$events; + while ( 1 ) { + my $event; + eval { $event = $events->() }; + if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) { + $session->log->error(sprintf "Couldn't instance event asset %s to delete it", $x->id); + next; + } + last unless $event; + $event->purge; + } } } else { # TODO: Give users a form property to decide what events to update - # TODO: Make a workflow activity to do this, so that updating - # 1 million events doesn't kill the server. + # TODO: Make this use WebGUI::ProgressBar so 1 million events doesn't kill the server. # Just update related events my %properties = %{ $self->get }; delete $properties{startDate}; delete $properties{endDate}; delete $properties{url}; # addRevision will create a new url for us - my $events = $self->getLineage(["siblings"], { - #returnObjects => 1, + my $events = $self->getLineageIterator(["siblings"], { includeOnlyClasses => ['WebGUI::Asset::Event'], joinClass => 'WebGUI::Asset::Event', whereClause => q{Event.recurId = "}.$self->get("recurId").q{"}, }); - for my $eventId (@{$events}) { - my $event = WebGUI::Asset->newByDynamicClass($session, $eventId); - + while ( 1 ) { + my $event; + eval { $event = $events->() }; + if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) { + $session->log->error(sprintf "Couldn't instance event asset %s to update it", $x->id); + next; + } + last unless $event; # Add a revision $properties{ startDate } = $event->get("startDate"); $properties{ endDate } = $event->get("endDate"); diff --git a/lib/WebGUI/Asset/Post.pm b/lib/WebGUI/Asset/Post.pm index c0c468e41..3f1a5b8c6 100644 --- a/lib/WebGUI/Asset/Post.pm +++ b/lib/WebGUI/Asset/Post.pm @@ -59,14 +59,12 @@ sub _fixReplyCount { my $self = shift; my $asset = shift; - my $lastPost = $asset->getLineage( [ qw{ self descendants } ], { - returnObjects => 1, + my $lastPostId = $asset->getLineage( [ qw{ self descendants } ], { isa => 'WebGUI::Asset::Post', orderByClause => 'assetData.revisionDate desc', - limit => 1, } )->[0]; - if ($lastPost) { + if (my $lastPost = WebGUI::Asset->newByDynamicClass( $self->session, $lastPostId ) ) { $asset->incrementReplies( $lastPost->get( 'revisionDate' ), $lastPost->getId ); } else { @@ -1024,10 +1022,7 @@ sub paste { $self->next::method(@_); # First, figure out what Thread we're under - my $thread = $self->getLineage( [ qw{ self ancestors } ], { - returnObjects => 1, - isa => 'WebGUI::Asset::Post::Thread', - } )->[0]; + my $thread = $self->getThread; # If the pasted asset is not a thread we'll have to update the threadId of it and all posts below it. if ( $self->get('threadId') ne $self->getId ) { diff --git a/lib/WebGUI/Asset/Post/Thread.pm b/lib/WebGUI/Asset/Post/Thread.pm index 056832ed0..3cb93a6c5 100644 --- a/lib/WebGUI/Asset/Post/Thread.pm +++ b/lib/WebGUI/Asset/Post/Thread.pm @@ -492,7 +492,7 @@ Returns a list of the post objects in this thread, including the thread post its sub getPosts { my $self = shift; - $self->getLineage(["self","descendants"], { + return $self->getLineage(["self","descendants"], { returnObjects => 1, includeArchived => 1, includeOnlyClasses => ["WebGUI::Asset::Post","WebGUI::Asset::Post::Thread"], diff --git a/lib/WebGUI/Asset/Sku/ThingyRecord.pm b/lib/WebGUI/Asset/Sku/ThingyRecord.pm index 391759182..dde7278ee 100644 --- a/lib/WebGUI/Asset/Sku/ThingyRecord.pm +++ b/lib/WebGUI/Asset/Sku/ThingyRecord.pm @@ -356,7 +356,15 @@ sub getThingOptions { tie my %options, 'Tie::IxHash', ( "" => "" ); my $thingyIter = WebGUI::Asset->getRoot($session) ->getLineageIterator( ['descendants'], { includeOnlyClasses => ['WebGUI::Asset::Wobject::Thingy'], } ); - while ( my $thingy = $thingyIter->() ) { + while ( 1 ) { + my $thingy; + eval { $thingy = $thingyIter->() }; + if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) { + $session->log->error($x->full_message); + next; + } + last unless $thingy; + tie my %things, 'Tie::IxHash', ( $session->db->buildHash( "SELECT thingId, label FROM Thingy_things WHERE assetId=?", [ $thingy->getId ] ) ); $options{ $thingy->get('title') } = \%things; diff --git a/lib/WebGUI/Asset/Wobject/Collaboration.pm b/lib/WebGUI/Asset/Wobject/Collaboration.pm index af0798408..0283f1de4 100644 --- a/lib/WebGUI/Asset/Wobject/Collaboration.pm +++ b/lib/WebGUI/Asset/Wobject/Collaboration.pm @@ -27,13 +27,13 @@ use base qw(WebGUI::AssetAspect::RssFeed WebGUI::Asset::Wobject); #------------------------------------------------------------------- sub _computePostCount { my $self = shift; - return scalar @{$self->getLineage(['descendants'], {includeOnlyClasses => ['WebGUI::Asset::Post']})}; + return $self->getDescendantCount({includeOnlyClasses => ['WebGUI::Asset::Post']}); } #------------------------------------------------------------------- sub _computeThreadCount { my $self = shift; - return scalar @{$self->getLineage(['children'], {includeOnlyClasses => ['WebGUI::Asset::Post::Thread']})}; + return $self->getChildCount({includeOnlyClasses => ['WebGUI::Asset::Post::Thread']}); } #------------------------------------------------------------------- @@ -1387,11 +1387,19 @@ sub processPropertiesFromFormPost { $self->createSubscriptionGroup; } if ($updatePrivs) { - foreach my $descendant (@{$self->getLineage(["descendants"],{returnObjects=>1})}) { - $descendant->update({ - groupIdView=>$self->get("groupIdView"), - groupIdEdit=>$self->get("groupIdEdit") - }); + my $descendantIter = $self->getLineageIterator(['descendants']); + while ( 1 ) { + my $descendant; + eval { $descendant = $descendantIter->() }; + if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) { + $session->log->error($x->full_message); + next; + } + last unless $descendant; + $descendant->update({ + groupIdView=>$self->get("groupIdView"), + groupIdEdit=>$self->get("groupIdEdit") + }); } } $self->session->scratch->delete($self->getId."_sortBy"); @@ -1686,16 +1694,21 @@ sub www_unarchiveAll { my $pb = WebGUI::ProgressBar->new($session); my $i18n = WebGUI::International->new($session, 'Asset_Collaboration'); $pb->start($i18n->get('unarchive all'), $self->getUrl('func=edit')); - my $threadIds = $self->getLineage(['children'],{ + my $threadIter = $self->getLineageIterator(['children'],{ includeOnlyClasses => [ 'WebGUI::Asset::Post::Thread' ], statusToInclude => [ 'archived' ], } ); - ASSET: foreach my $threadId (@$threadIds) { - my $thread = WebGUI::Asset->newPending($session, $threadId); - if (!$thread || !$thread->canEdit) { - next ASSET; + ASSET: while ( 1 ) { + my $thread; + eval { $thread = $threadIter->() }; + if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) { + $session->log->error($x->full_message); + next; + } + last unless $thread; + if ($thread->canEdit) { + $thread->unarchive; } - $thread->unarchive; } return $pb->finish( $self->getUrl('func=edit') ); } diff --git a/lib/WebGUI/Asset/Wobject/Dashboard.pm b/lib/WebGUI/Asset/Wobject/Dashboard.pm index 0590e4b64..4affa91e3 100644 --- a/lib/WebGUI/Asset/Wobject/Dashboard.pm +++ b/lib/WebGUI/Asset/Wobject/Dashboard.pm @@ -189,9 +189,16 @@ sub getEditForm { my $i18n = WebGUI::International->new($self->session, "Asset_Dashboard"); if ($self->session->form->process("func") ne "add") { my @assetsToHide = split("\n",$self->getValue("assetsToHide")); - my $children = $self->getLineage(["children"],{"returnObjects"=>1, excludeClasses=>["WebGUI::Asset::Wobject::Layout"]}); + my $childIter = $self->getLineageIterator(["children"],{excludeClasses=>["WebGUI::Asset::Wobject::Layout"]}); my %childIds; - foreach my $child (@{$children}) { + while ( 1 ) { + my $child; + eval { $child = $childIter->() }; + if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) { + $session->log->error($x->full_message); + next; + } + last unless $child; $childIds{$child->getId} = $child->getTitle.' ['.ref($child).']'; } $tabform->getTab("display")->checkList( @@ -255,9 +262,16 @@ their templates. sub prepareView { my $self = shift; $self->SUPER::prepareView; - my $children = $self->getLineage( ["children"], { returnObjects=>1, excludeClasses=>["WebGUI::Asset::Wobject::Layout","WebGUI::Asset::Wobject::Dashboard"] }); my @hidden = split("\n",$self->get("assetsToHide")); - foreach my $child (@{$children}) { + my $childIter = $self->getLineageIterator( ["children"], {excludeClasses=>["WebGUI::Asset::Wobject::Layout","WebGUI::Asset::Wobject::Dashboard"] }); + while ( 1 ) { + my $child; + eval { $child = $childIter->() }; + if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) { + $session->log->error($x->full_message); + next; + } + last unless $child; unless (isIn($child->getId, @hidden) || !($child->canView)) { $self->session->style->setRawHeadTags($child->getExtraHeadTags); $child->prepareView; @@ -323,8 +337,9 @@ sub view { ); my $templateId = $self->get("templateId"); - my $children = $self->getLineage( ["children"], { returnObjects=>1, excludeClasses=>["WebGUI::Asset::Wobject::Layout","WebGUI::Asset::Wobject::Dashboard"] }); + # XXX Not using getLineageIterator because we loop over the children three times... # I'm sure there's a more efficient way to do this. We'll figure it out someday. + my $children = $self->getLineage( ["children"], { returnObjects=>1, excludeClasses=>["WebGUI::Asset::Wobject::Layout","WebGUI::Asset::Wobject::Dashboard"] }); my @positions = split(/\./,$self->getContentPositions); my @hidden = split("\n",$self->get("assetsToHide")); foreach my $child (@{$children}) { diff --git a/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm b/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm index 3c4713911..560bf2887 100644 --- a/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm +++ b/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm @@ -607,10 +607,10 @@ returns true if the EMS has subission forms attached sub hasSubmissionForms { my $self = shift; # are there ~any~ forms attached to this ems? - my $res = $self->getLineage(['children'],{ limit => 1, + my $count = $self->getDescendantCount({ includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'], } ); - return scalar(@$res); + return $count; } #------------------------------------------------------------------- @@ -1038,12 +1038,12 @@ then call www_editSubmission on it sub www_editSubmission { my $self = shift; my $submissionId = $self->session->form->get('submissionId'); - my $asset = $self->getLineage(['descendants'], { returnObjects => 1, + my $asset = $self->getLineageIterator(['descendants'], { joinClass => "WebGUI::Asset::EMSSubmission", whereClause => 'submissionId = ' . int($submissionId), includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'], } ); - return $asset->[0]->www_editSubmission; + return $asset->()->www_editSubmission; } @@ -1389,6 +1389,7 @@ sub www_getBadgesAsJson { my ($db, $form) = $session->quick(qw(db form)); my %results = (); $results{records} = []; + # TODO: Use getLineageIterator here instead BADGE: foreach my $badge (@{$self->getBadges}) { next BADGE unless $badge->canView; push(@{$results{records}}, { diff --git a/lib/WebGUI/Asset/Wobject/Folder.pm b/lib/WebGUI/Asset/Wobject/Folder.pm index 21a50c3ea..9b3ae43bf 100644 --- a/lib/WebGUI/Asset/Wobject/Folder.pm +++ b/lib/WebGUI/Asset/Wobject/Folder.pm @@ -122,7 +122,15 @@ Overridden to check the revision dates of children as well sub getContentLastModified { my $self = shift; my $mtime = $self->get("revisionDate"); - foreach my $child (@{ $self->getLineage(["children"],{returnObjects=>1}) }) { + my $childIter = $self->getLineageIterator(["children"]); + while ( 1 ) { + my $child; + eval { $child = $childIter->() }; + if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) { + $session->log->error($x->full_message); + next; + } + last unless $child; my $child_mtime = $child->getContentLastModified; $mtime = $child_mtime if ($child_mtime > $mtime); } @@ -233,7 +241,7 @@ sub view { my $vars = $self->getTemplateVars; # TODO: Getting the children template vars should be a seperate method. - my %rules = ( returnObjects => 1); + my %rules = ( ); if ( $self->get( "sortAlphabetically" ) ) { $rules{ orderByClause } = "assetData.title " . $self->get( "sortOrder" ); } @@ -241,9 +249,16 @@ sub view { $rules{ orderByClause } = "asset.lineage " . $self->get( "sortOrder" ); } - my $children = $self->getLineage( ["children"], \%rules); - foreach my $child ( @{ $children } ) { - # TODO: Instead of this it should be using $child->getTemplateVars || $child->get + my $childIter = $self->getLineageIterator( ["children"], \%rules); + while ( 1 ) { + my $child; + eval { $child = $childIter->() }; + if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) { + $session->log->error($x->full_message); + next; + } + last unless $child; + # TODO: Instead of this it should be using $child->getTemplateVars || $child->get if ( $child->isa("WebGUI::Asset::Wobject::Folder") ) { push @{ $vars->{ "subfolder_loop" } }, { id => $child->getId, diff --git a/lib/WebGUI/Asset/Wobject/Gallery.pm b/lib/WebGUI/Asset/Wobject/Gallery.pm index 3a3b059c0..3b70ab365 100644 --- a/lib/WebGUI/Asset/Wobject/Gallery.pm +++ b/lib/WebGUI/Asset/Wobject/Gallery.pm @@ -927,17 +927,21 @@ sub hasSpaceAvailable { # Compile the amount of disk space used my $maxSpace = $self->get( "maxSpacePerUser" ) * ( 1_024 ** 2 ); # maxSpacePerUser is in MB my $spaceUsed = 0; - my $fileIds - = $self->getLineage( [ 'descendants' ], { + my $fileIter + = $self->getLineageIterator( [ 'descendants' ], { joinClass => 'WebGUI::Asset::File::GalleryFile', whereClause => 'ownerUserId = ' . $db->quote( $userId ), } ); - for my $assetId ( @{ $fileIds } ) { - my $asset = WebGUI::Asset->newByDynamicClass( $self->session, $assetId ); - next unless $asset; - $spaceUsed += $asset->get( 'assetSize' ); - + while ( 1 ) { + my $file; + eval { $file = $fileIter->() }; + if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) { + $session->log->error($x->full_message); + next; + } + last unless $file; + $spaceUsed += $file->get( 'assetSize' ); return 0 if ( $spaceUsed + $spaceWanted >= $maxSpace ); } diff --git a/lib/WebGUI/Asset/Wobject/Layout.pm b/lib/WebGUI/Asset/Wobject/Layout.pm index 69e0a9997..fb176ca0d 100644 --- a/lib/WebGUI/Asset/Wobject/Layout.pm +++ b/lib/WebGUI/Asset/Wobject/Layout.pm @@ -180,9 +180,16 @@ sub getEditForm { } else { my @assetsToHide = split("\n",$self->getValue("assetsToHide")); - my $children = $self->getLineage(["children"],{"returnObjects"=>1, excludeClasses=>["WebGUI::Asset::Wobject::Layout"]}); + my $childIter = $self->getLineageIterator(["children"],{excludeClasses=>["WebGUI::Asset::Wobject::Layout"]}); my %childIds; - foreach my $child (@{$children}) { + while ( 1 ) { + my $child; + eval { $child = $childIter->() }; + if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) { + $session->log->error($x->full_message); + next; + } + last unless $child; $childIds{$child->getId} = $child->getTitle; } $extraFields{assetsToHide} = { @@ -256,11 +263,18 @@ sub prepareView { my %placeHolder; my @children; - - for my $child ( @{ $self->getLineage( ["children"], { - returnObjects => 1, + + my $childIter = $self->getLineageIterator( ["children"], { excludeClasses => ["WebGUI::Asset::Wobject::Layout"], - } ) } ) { + } ); + while ( 1 ) { + my $child; + eval { $child = $childIter->() }; + if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) { + $session->log->error($x->full_message); + next; + } + last unless $child; my $assetId = $child->getId; next if ($hidden{$assetId} || ! $child->canView); @@ -412,7 +426,15 @@ sub getContentLastModified { # Buggo: this is a little too conservative. Children that are hidden maybe shouldn't count. Hm. my $self = shift; my $mtime = $self->SUPER::getContentLastModified; - foreach my $child (@{$self->getLineage(["children"],{returnObjects=>1, excludeClasses=>['WebGUI::Asset::Wobject::Layout']})}) { + my $childIter = $self->getLineageIterator(["children"],{excludeClasses=>['WebGUI::Asset::Wobject::Layout']}); + while ( 1 ) { + my $child; + eval { $child = $childIter->() }; + if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) { + $session->log->error($x->full_message); + next; + } + last unless $child; my $child_mtime = $child->getContentLastModified; $mtime = $child_mtime if ($child_mtime > $mtime); } diff --git a/lib/WebGUI/Asset/Wobject/Matrix.pm b/lib/WebGUI/Asset/Wobject/Matrix.pm index fd81b0d79..dd56adace 100644 --- a/lib/WebGUI/Asset/Wobject/Matrix.pm +++ b/lib/WebGUI/Asset/Wobject/Matrix.pm @@ -315,11 +315,17 @@ sub deleteAttribute { [$attributeId,$self->getId]); # recalculate scores for MatrixListings - my @listings = @{ $self->getLineage(['descendants'], { + my $listingIter = $self->getLineageIterator(['descendants'], { includeOnlyClasses => ['WebGUI::Asset::MatrixListing'], - returnObjects => 1, - }) }; - foreach my $listing (@listings){ + }); + while ( 1 ) { + my $listing; + eval { $listing = $listingIter->() }; + if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) { + $session->log->error($x->full_message); + next; + } + last unless $listing; $listing->updateScore; } @@ -661,17 +667,23 @@ sub view { if ($self->canEdit){ # Get all the MatrixListings that are still pending. - my @pendingListings = @{ $self->getLineage(['descendants'], { + my $pendingIter = $self->getLineageIterator(['descendants'], { includeOnlyClasses => ['WebGUI::Asset::MatrixListing'], orderByClause => "revisionDate asc", - returnObjects => 1, statusToInclude => ['pending'], - }) }; - foreach my $pendingListing (@pendingListings){ + }); + while ( 1 ) { + my $pending; + eval { $pending = $pendingIter->() }; + if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) { + $session->log->error($x->full_message); + next; + } + last unless $pending; push (@{ $var->{pending_loop} }, { - url => $pendingListing->getUrl - ."?func=view;revision=".$pendingListing->get('revisionDate'), - name => $pendingListing->get('title'), + url => $pending->getUrl + ."?func=view;revision=".$pending->get('revisionDate'), + name => $pending->get('title'), }); } } @@ -747,18 +759,23 @@ sub view { # Get the 5 MatrixListings that were last updated as objects using getLineage. - my @lastUpdatedListings = @{ $self->getLineage(['descendants'], { + my $lastUpdatedIter = $self->getLineageIterator(['descendants'], { includeOnlyClasses => ['WebGUI::Asset::MatrixListing'], joinClass => "WebGUI::Asset::MatrixListing", orderByClause => "lastUpdated desc", - limit => 5, - returnObjects => 1, - }) }; - foreach my $lastUpdatedListing (@lastUpdatedListings){ + }); + for ( 1..5 ) { + my $lastUpdated; + eval { $lastUpdated = $lastUpdatedIter->() }; + if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) { + $session->log->error($x->full_message); + next; + } + last unless $lastUpdated; push (@{ $varStatistics->{last_updated_loop} }, { - url => $lastUpdatedListing->getUrl, - name => $lastUpdatedListing->get('title'), - lastUpdated => $session->datetime->epochToHuman($lastUpdatedListing->get('lastUpdated'),"%z") + url => $lastUpdated->getUrl, + name => $lastUpdated->get('title'), + lastUpdated => $session->datetime->epochToHuman($lastUpdated->get('lastUpdated'),"%z") }); } $varStatistics->{lastUpdated_sortButton} = "