Index: kernel/application.php =================================================================== --- kernel/application.php (revision 14133) +++ kernel/application.php (working copy) @@ -220,6 +220,13 @@ */ var $isAdmin = false; + /** + * Tells, that Daemon mode is used (minimized database query count, less functionality, more speed) + * + * @var bool + */ + var $isDaemon = false; + /** * Instance of site domain object * @@ -277,6 +284,7 @@ } $this->isAdmin = constOn('ADMIN'); + $this->isDaemon = constOn('DAEMON'); if (!constOn('SKIP_OUT_COMPRESSION')) { ob_start(); // collect any output from method (other then tags) into buffer @@ -835,7 +843,7 @@ $this->setCache($serial_name, (int)$this->getCache($serial_name) + 1); - if (!defined('IS_INSTALL') || !IS_INSTALL) { + if (!(defined('IS_INSTALL') && IS_INSTALL) && !$this->isDaemon) { // delete cached mod-rewrite urls related to given prefix and id $delete_clause = isset($id) ? $prefix . ':' . $id : $prefix; @@ -2278,6 +2286,10 @@ function LoadCache() { + if ($this->isDaemon) { + return ; + } + // TODO: maybe language part isn't required, since same phrase from different languages have one ID now $cache_key = $this->GetVar('t') . $this->GetVar('m_theme') . $this->GetVar('m_lang') . $this->isAdmin; @@ -2309,7 +2321,7 @@ */ function LoadStructureTemplateMapping() { - if (!$this->isAdmin) { + if (!$this->isAdmin && !$this->isDaemon) { $category_helper =& $this->Application->recallObject('CategoryHelper'); /* @var $category_helper CategoryHelper */ @@ -2319,6 +2331,10 @@ function UpdateCache() { + if ($this->isDaemon) { + return ; + } + $update = false; //something changed $update = $update || $this->Phrases->NeedsCacheUpdate(); @@ -3227,7 +3243,7 @@ */ function resetCounters($tables) { - if (constOn('IS_INSTALL')) { + if (constOn('IS_INSTALL') || $this->isDaemon) { return ; } Index: kernel/languages/phrases_cache.php =================================================================== --- kernel/languages/phrases_cache.php (revision 14103) +++ kernel/languages/phrases_cache.php (working copy) @@ -181,7 +181,7 @@ function LoadPhrases($ids) { - if ( !is_array($ids) || !implode('', $ids) ) { + if ( !is_array($ids) || !implode('', $ids) || $this->Application->isDaemon ) { return; } Index: kernel/startup.php =================================================================== --- kernel/startup.php (revision 14103) +++ kernel/startup.php (working copy) @@ -103,6 +103,10 @@ define('DOMAIN', getArrayValue($vars, 'Domain')); + if ( isset($vars['DaemonMode']) ) { + safeDefine('DAEMON', $vars['DaemonMode']); // safedefine, because could be defined in index.php directly + } + ini_set('memory_limit', '50M'); define('MODULES_PATH', FULL_PATH . DIRECTORY_SEPARATOR . 'modules'); Index: units/agents/agent_eh.php =================================================================== --- units/agents/agent_eh.php (revision 14103) +++ units/agents/agent_eh.php (working copy) @@ -39,6 +39,10 @@ */ function OnRefreshAgents(&$event) { + if ($this->Application->isDaemon) { + return ; + } + $regular_events = $this->Application->EventManager->getRegularEvents(true); $object =& $event->getObject( Array ('skip_autoload' => true) ); Index: units/categories/categories_event_handler.php =================================================================== --- units/categories/categories_event_handler.php (revision 14161) +++ units/categories/categories_event_handler.php (working copy) @@ -2003,6 +2003,10 @@ */ function OnAfterRebuildThemes(&$event) { + if ($this->Application->isDaemon) { + return ; + } + $sql = 'SELECT t.ThemeId, CONCAT( tf.FilePath, \'/\', tf.FileName ) AS Path, tf.FileMetaInfo FROM '.TABLE_PREFIX.'ThemeFiles AS tf LEFT JOIN '.TABLE_PREFIX.'Theme AS t ON t.ThemeId = tf.ThemeId Index: units/custom_data/custom_data_event_handler.php =================================================================== --- units/custom_data/custom_data_event_handler.php (revision 14130) +++ units/custom_data/custom_data_event_handler.php (working copy) @@ -94,6 +94,10 @@ */ function getCustomFields() { + if ($this->Application->isDaemon) { + return Array (); + } + $sql = 'SELECT * FROM '.TABLE_PREFIX.'CustomField'; $ret = $this->Conn->Query($sql, 'CustomFieldId'); Index: units/forms/forms/forms_eh.php =================================================================== --- units/forms/forms/forms_eh.php (revision 14103) +++ units/forms/forms/forms_eh.php (working copy) @@ -33,7 +33,7 @@ function OnCreateSubmissionNodes(&$event) { - if (defined('IS_INSTALL') && IS_INSTALL) { + if ( (defined('IS_INSTALL') && IS_INSTALL) || $this->Application->isDaemon ) { // skip any processing, because Forms table doesn't exists until install is finished return ; } Index: units/helpers/curl_helper.php =================================================================== --- units/helpers/curl_helper.php (revision 14103) +++ units/helpers/curl_helper.php (working copy) @@ -132,13 +132,16 @@ // hardcoded options CURLOPT_RETURNTRANSFER => 1, CURLOPT_REFERER => PROTOCOL.SERVER_NAME, - CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'], - + // don't verify SSL certificates CURLOPT_SSL_VERIFYPEER => false, CURLOPT_HTTPHEADER => Array ('Expect:'), ); + if ( isset($_SERVER['HTTP_USER_AGENT']) ) { + $default_options[CURLOPT_USERAGENT] = $_SERVER['HTTP_USER_AGENT']; + } + if ($this->requestHeaders) { $default_options[CURLOPT_HTTPHEADER] = $this->prepareHeaders(); } Index: units/helpers/language_import_helper.php =================================================================== --- units/helpers/language_import_helper.php (revision 14103) +++ units/helpers/language_import_helper.php (working copy) @@ -130,7 +130,7 @@ $this->lang_object =& $this->Application->recallObject('lang.import', null, Array ('skip_autoload' => true)); - if (!(defined('IS_INSTALL') && IS_INSTALL)) { + if (!(defined('IS_INSTALL') && IS_INSTALL) && !$this->Application->isDaemon) { // perform only, when not in installation mode $this->_updateEventsCache(); } @@ -152,7 +152,7 @@ function performImport($filename, $phrase_types, $module_ids, $import_mode = LANG_SKIP_EXISTING) { // define the XML parsing routines/functions to call based on the handler path - if (!file_exists($filename) || !$phrase_types /*|| !$module_ids*/) { + if (!file_exists($filename) || !$phrase_types /*|| !$module_ids*/ || $this->Application->isDaemon) { return false; } Index: units/helpers/themes_helper.php =================================================================== --- units/helpers/themes_helper.php (revision 14103) +++ units/helpers/themes_helper.php (working copy) @@ -402,6 +402,10 @@ */ function refreshThemes() { + if ($this->Application->isDaemon) { + return ; + } + $themes_found = Array(); $skip_filenames = Array ('.', '..', 'CVS', '.svn');