From 3809c1614f66aa3ed52b1ceb085830e2c182b863 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 7 Oct 2011 11:14:55 +0200 Subject: [PATCH] API CHANGE Require ADMIN permissions for performance-heavy tasks in CMSMain: getpagecount() and publishall(), and using increase_time_limit_to() which respects higher max_execution_time settings --- code/controllers/CMSMain.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/code/controllers/CMSMain.php b/code/controllers/CMSMain.php index 1e61f853..b53a47a1 100644 --- a/code/controllers/CMSMain.php +++ b/code/controllers/CMSMain.php @@ -1006,8 +1006,6 @@ JS; $page->HasBrokenLink = 0; $page->HasBrokenFile = 0; - $lastUsage = (memory_get_usage() - $lastPoint); - $lastPoint = memory_get_usage(); $content->setValue($page->Content); $content->saveInto($page); @@ -1066,7 +1064,11 @@ JS; * Helper function to get page count */ function getpagecount() { - ini_set('max_execution_time', 0); + if(!Permission::check('ADMIN')) return Security::permissionFailure($this); + + increase_time_limit_to(); + increase_memory_limit_to(); + $excludePages = split(" *, *", $_GET['exclude']); $pages = DataObject::get("SiteTree", "\"ParentID\" = 0"); @@ -1093,8 +1095,10 @@ JS; } function publishall($request) { - ini_set("memory_limit", -1); - ini_set('max_execution_time', 0); + if(!Permission::check('ADMIN')) return Security::permissionFailure($this); + + increase_time_limit_to(); + increase_memory_limit_to(); $response = "";