From 8401101d5051c4ccad140fc4b062fa9c780d06d9 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Mon, 1 Apr 2013 15:08:21 +0300 Subject: Moved hard-coded fetch timeout values into config file to allow site-level tuning --- include/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index b9c30c6ce..fa63c9baa 100644 --- a/include/functions.php +++ b/include/functions.php @@ -306,8 +306,8 @@ array("If-Modified-Since: ".gmdate('D, d M Y H:i:s \G\M\T', $timestamp))); } - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout ? $timeout : 15); - curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : 45); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout ? $timeout : FILE_FETCH_CONNECT_TIMEOUT); + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : FILE_FETCH_TIMEOUT); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("safe_mode")); curl_setopt($ch, CURLOPT_MAXREDIRS, 20); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); -- cgit v1.2.3 From 046ec657602ea46e7b32d3f3e387104d89ac6d8a Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Mon, 1 Apr 2013 18:32:05 +0300 Subject: Move tuning settings to different file so config.php isn't overcrowded by default --- include/functions.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index fa63c9baa..7d1cf6b9a 100644 --- a/include/functions.php +++ b/include/functions.php @@ -30,6 +30,27 @@ require_once 'config.php'; + /** + * Define a constant if not already defined + * + * @param string $name The constant name. + * @param mixed $value The constant value. + * @access public + * @return boolean True if defined successfully or not. + */ + function define_default($name, $value) { + // Note: performence freaks should define everything in + // tunables.php in config.php becasue if will make defined() + // run much faster, see 'tris+php at tfconsulting dot com dot + // au' comment here: + // http://www.php.net/manual/en/function.defined.php#89886 + defined($name) or define($name, $value); + } + + // Require tunables.php to define tunable constants (That may have + // already been denied in config.php) + require_once 'tunables.php'; + if (DB_TYPE == "pgsql") { define('SUBSTRING_FOR_DATE', 'SUBSTRING_FOR_DATE'); } else { -- cgit v1.2.3 From 9ef8798bec84b3aa86dc699681ea4f21efb3cefa Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Tue, 2 Apr 2013 21:29:10 +0300 Subject: No more "tunables.php" defaults dumped into "functions.php" --- include/functions.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index d99f6a64b..ee575568a 100644 --- a/include/functions.php +++ b/include/functions.php @@ -40,16 +40,25 @@ */ function define_default($name, $value) { // Note: performence freaks should define everything in - // tunables.php in config.php becasue if will make defined() - // run much faster, see 'tris+php at tfconsulting dot com dot - // au' comment here: + // config.php becasue if will make defined() run much faster, + // see comment by 'tris+php at tfconsulting dot com dot au' + // here: // http://www.php.net/manual/en/function.defined.php#89886 defined($name) or define($name, $value); } - // Require tunables.php to define tunable constants (That may have - // already been denied in config.php) - require_once 'tunables.php'; + ///// Some defaults that you can override in config.php ////// + + define_default('FEED_FETCH_TIMEOUT', 45); + // How may seconds to wait for response when requesting feed from a site + define_default('FEED_FETCH_NO_CACHE_TIMEOUT', 15); + // How may seconds to wait for response when requesting feed from a + // site when that feed wasn't cached before + define_default('FILE_FETCH_TIMEOUT', 45); + // Default timeout when fetching files from remote sites + define_default('FILE_FETCH_CONNECT_TIMEOUT', 15); + // How many seconds to wait for initial response from website when + // fetching files from remote sites if (DB_TYPE == "pgsql") { define('SUBSTRING_FOR_DATE', 'SUBSTRING_FOR_DATE'); -- cgit v1.2.3