MINOR FIX: prevents looping over an empty array

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@86166 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Geoff Munn 2009-09-13 22:25:41 +00:00
parent 966155a054
commit 85ee1007c4

View File

@ -1102,24 +1102,25 @@ JS;
$start = 0; $start = 0;
$pages = DataObject::get("SiteTree", "", "", "", "$start,30"); $pages = DataObject::get("SiteTree", "", "", "", "$start,30");
$count = 0; $count = 0;
while(true) { if($pages){
foreach($pages as $page) { while(true) {
if($page && !$page->canPublish()) return Security::permissionFailure($this); foreach($pages as $page) {
if($page && !$page->canPublish()) return Security::permissionFailure($this);
$page->doPublish();
$page->destroy(); $page->doPublish();
unset($page); $page->destroy();
$count++; unset($page);
$response .= "<li>$count</li>"; $count++;
} $response .= "<li>$count</li>";
if($pages->Count() > 29) { }
$start += 30; if($pages->Count() > 29) {
$pages = DataObject::get("SiteTree", "", "", "", "$start,30"); $start += 30;
} else { $pages = DataObject::get("SiteTree", "", "", "", "$start,30");
break; } else {
break;
}
} }
} }
$response .= sprintf(_t('CMSMain.PUBPAGES',"Done: Published %d pages"), $count); $response .= sprintf(_t('CMSMain.PUBPAGES',"Done: Published %d pages"), $count);
} else { } else {