BUGFIX #6162 CMSMain::publishall() fails when over 30 pages (thanks natmchugh!) (from r114940)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@114941 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2010-12-14 01:32:01 +00:00 committed by Sam Minnee
parent 357b868b4f
commit 77c5701fa6
3 changed files with 62 additions and 20 deletions

View File

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

View File

@ -38,7 +38,7 @@ class CMSMainTest extends FunctionalTest {
$response = $this->get("admin/cms/publishall?confirm=1"); $response = $this->get("admin/cms/publishall?confirm=1");
$this->assertContains( $this->assertContains(
sprintf(_t('CMSMain.PUBPAGES',"Done: Published %d pages"), 8), sprintf(_t('CMSMain.PUBPAGES',"Done: Published %d pages"), 30),
$response->getBody() $response->getBody()
); );
@ -225,4 +225,4 @@ class CMSMainTest extends FunctionalTest {
// TODO Logout // TODO Logout
$this->session()->inst_set('loggedInAs', NULL); $this->session()->inst_set('loggedInAs', NULL);
} }
} }

View File

@ -13,6 +13,50 @@ Page:
Parent: =>Page.page3 Parent: =>Page.page3
page4: page4:
Title: Page 4 Title: Page 4
page5:
Title: Page 5
page6:
Title: Page 6
page7:
Title: Page 7
page8:
Title: Page 8
page9:
Title: Page 9
page10:
Title: Page 10
page11:
Title: Page 11
page12:
Title: Page 12
page13:
Title: Page 13
page14:
Title: Page 14
page15:
Title: Page 15
page16:
Title: Page 16
page17:
Title: Page 17
page18:
Title: Page 18
page19:
Title: Page 19
page20:
Title: Page 20
page21:
Title: Page 21
page22:
Title: Page 22
page23:
Title: Page 23
page24:
Title: Page 24
page25:
Title: Page 25
page26:
Title: Page 26
home: home:
Title: Home Title: Home
URLSegment: home URLSegment: home
@ -82,4 +126,4 @@ RedirectorPage:
page5: page5:
Title: Page 5 Title: Page 5
RedirectionType: External RedirectionType: External
ExternalURL: http://www.google.com ExternalURL: http://www.google.com