From 22ac12c0c504c5810b8f7b5fb2a811ea09834286 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Tue, 14 Dec 2010 01:29:38 +0000 Subject: [PATCH] BUGFIX #6162 CMSMain::publishall() fails when over 30 pages (thanks natmchugh!) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@114940 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/CMSMain.php | 32 ++++++++++++++---------------- tests/CMSMainTest.php | 4 ++-- tests/CMSMainTest.yml | 46 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 62 insertions(+), 20 deletions(-) diff --git a/code/CMSMain.php b/code/CMSMain.php index 0347db99..9e074e99 100755 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -1180,23 +1180,21 @@ JS; $start = 0; $pages = DataObject::get("SiteTree", "", "", "", "$start,30"); $count = 0; - if($pages){ - while(true) { - foreach($pages as $page) { - if($page && !$page->canPublish()) return Security::permissionFailure($this); - - $page->doPublish(); - $page->destroy(); - unset($page); - $count++; - $response .= "
  • $count
  • "; - } - if($pages->Count() > 29) { - $start += 30; - $pages = DataObject::get("SiteTree", "", "", "", "$start,30"); - } else { - break; - } + while($pages) { + foreach($pages as $page) { + if($page && !$page->canPublish()) return Security::permissionFailure($this); + + $page->doPublish(); + $page->destroy(); + unset($page); + $count++; + $response .= "
  • $count
  • "; + } + if($pages->Count() > 29) { + $start += 30; + $pages = DataObject::get("SiteTree", "", "", "", "$start,30"); + } else { + break; } } $response .= sprintf(_t('CMSMain.PUBPAGES',"Done: Published %d pages"), $count); diff --git a/tests/CMSMainTest.php b/tests/CMSMainTest.php index b7c237d4..cca5c155 100644 --- a/tests/CMSMainTest.php +++ b/tests/CMSMainTest.php @@ -38,7 +38,7 @@ class CMSMainTest extends FunctionalTest { $response = Director::test("admin/cms/publishall", array('confirm' => 1), $this->session()); $this->assertContains( - sprintf(_t('CMSMain.PUBPAGES',"Done: Published %d pages"), 8), + sprintf(_t('CMSMain.PUBPAGES',"Done: Published %d pages"), 30), $response->getBody() ); @@ -220,4 +220,4 @@ class CMSMainTest extends FunctionalTest { // TODO Logout $this->session()->inst_set('loggedInAs', NULL); } -} \ No newline at end of file +} diff --git a/tests/CMSMainTest.yml b/tests/CMSMainTest.yml index 09b1168e..1c8944e8 100644 --- a/tests/CMSMainTest.yml +++ b/tests/CMSMainTest.yml @@ -13,6 +13,50 @@ Page: Parent: =>Page.page3 page4: 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: Title: Home URLSegment: home @@ -66,4 +110,4 @@ RedirectorPage: page5: Title: Page 5 RedirectionType: External - ExternalURL: http://www.google.com \ No newline at end of file + ExternalURL: http://www.google.com