Index: kernel/globals.php =================================================================== --- kernel/globals.php (revision 15569) +++ kernel/globals.php (working copy) @@ -739,6 +739,21 @@ return $id_part_1 . $id_part_2 . $id_part_3; } + + /** + * Changes script resource limits. Omitted argument results in limit removal. + * + * @static + * @param string|int $memory_limit + * @param int $time_limit + * @return void + * @access public + */ + public static function setResourceLimit($memory_limit = null, $time_limit = null) + { + set_time_limit(isset($time_limit) ? $time_limit : 0); + ini_set('memory_limit', isset($memory_limit) ? $memory_limit : -1); + } } /** Index: kernel/processors/main_processor.php =================================================================== --- kernel/processors/main_processor.php (revision 15548) +++ kernel/processors/main_processor.php (working copy) @@ -1060,8 +1060,7 @@ } // xml documents are usually long - set_time_limit(0); - ini_set('memory_limit', -1); + kUtil::setResourceLimit(); if ( !$this->Application->GetVar('debug') ) { return $this->Application->XMLHeader(getArrayValue($params, 'xml_version')); Index: kernel/utility/debugger/debugger_responce.php =================================================================== --- kernel/utility/debugger/debugger_responce.php (revision 15532) +++ kernel/utility/debugger/debugger_responce.php (working copy) @@ -12,8 +12,8 @@ * See http://www.in-portal.org/license for copyright notices and details. */ + set_time_limit(0); ini_set('memory_limit', -1); - set_time_limit(0); define('FULL_PATH', realpath(dirname(__FILE__) . '/../../../..')); Index: units/categories/categories_event_handler.php =================================================================== --- units/categories/categories_event_handler.php (revision 15541) +++ units/categories/categories_event_handler.php (working copy) @@ -2283,8 +2283,7 @@ return; } - set_time_limit(0); - ini_set('memory_limit', -1); + kUtil::setResourceLimit(); $dummy = $this->Application->recallObject($event->Prefix . '.rebuild', NULL, Array ('skip_autoload' => true)); /* @var $dummy CategoriesItem */ Index: units/helpers/deployment_helper.php =================================================================== --- units/helpers/deployment_helper.php (revision 15569) +++ units/helpers/deployment_helper.php (working copy) @@ -86,8 +86,7 @@ { parent::__construct(); - set_time_limit(0); - ini_set('memory_limit', -1); + kUtil::setResourceLimit(); $this->isCommandLine = isset($GLOBALS['argv']) && count($GLOBALS['argv']); Index: units/helpers/image_helper.php =================================================================== --- units/helpers/image_helper.php (revision 15505) +++ units/helpers/image_helper.php (working copy) @@ -182,8 +182,7 @@ list ($read_function, $write_function, $file_extension) = explode(':', $resize_map[$mime_type]); // when source image has large dimensions (over 1MB filesize), then 16M is not enough - set_time_limit(0); - ini_set('memory_limit', -1); + kUtil::setResourceLimit(); $src_image_rs = @$read_function($src_image); if ($src_image_rs) { Index: units/helpers/language_import_helper.php =================================================================== --- units/helpers/language_import_helper.php (revision 15569) +++ units/helpers/language_import_helper.php (working copy) @@ -139,8 +139,7 @@ parent::__construct(); // "core/install/english.lang", phrase count: 3318, xml parse time on windows: 10s, insert time: 0.058s - set_time_limit(0); - ini_set('memory_limit', -1); + kUtil::setResourceLimit(); $this->lang_object = $this->Application->recallObject('lang.import', null, Array ('skip_autoload' => true));