summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2019-01-04 16:21:09 +0100
committerUrban Müller2019-01-04 16:25:32 +0100
commitb1898d315f414f69d497b2cf5fdc6ae686aac215 (patch)
tree3a61ccc735cdcdcadc14485992f9200ef660f329
parent6c954dfe10672c290329e6a19210b74b30c39132 (diff)
downloaditools-b1898d315f414f69d497b2cf5fdc6ae686aac215.tar.gz
itools-b1898d315f414f69d497b2cf5fdc6ae686aac215.tar.bz2
itools-b1898d315f414f69d497b2cf5fdc6ae686aac215.zip
allow omitting id if default maxage
-rw-r--r--it_url.class12
1 files changed, 6 insertions, 6 deletions
diff --git a/it_url.class b/it_url.class
index 6e32019..531af8b 100644
--- a/it_url.class
+++ b/it_url.class
@@ -406,7 +406,7 @@ static function get_cache_dir($p)
/**
* Construct a local file name to cache an URL. Takes language into account. Named args:
- * @param $p['url'] remote url to get
+ * @param $p['url'] remote url to get
* @param $p['cachedir'] directory to store cache files in, @see get_cache_dir
* @param $p['cachefilename'] Use this filename instead of calculating your own if this is given
* @param $p['data'] POST data array with key-value pairs
@@ -428,11 +428,11 @@ static function get_cache_filename($p)
* Store contents of url in a file and return file name. Threadsafe: Provides locking. Called statically.
* Requires webserver writeable directory in $p['cachdedir']. Params in associative array p:
* @param $p['url'] url to get
- * @param $p['id'] mandatory: dirname for cached files; same id should have same expire policy
+ * @param $p['id'] dirname for cached files; same id should have same expire policy
* @param $p['headers'] optional array of HTTP headers to send
* @param $p['cachedir'] directory to store cache files in, @see get_cache_dir
* @param $p['timeout'] timeout in seconds, default 10. fractions allowed
- * @param $p['maxage'] maximum age of cache entries in seconds, default 86400
+ * @param $p['maxage'] maximum age of cache entries in seconds, default 86400. id mandatory if given
* @param $p['cleanbefore'] maximum daytime when attempting cleanup, default 7200
* @param $p['preprocess'] callback function (or array for methods) to change received file or array('function' => ..., 'in' => $src, 'out' => $dst, ...) with callback function plus args
* @param $p['safety'] DEPRECATED. see $p['it_error']
@@ -443,14 +443,14 @@ static function get_cache_filename($p)
*/
function get_cache($p = array())
{
+ if (!$p['id'] && $p['maxage'])
+ it::error("calling get_cache with maxage and without id");
+
$p += ['timeout' => 10, 'maxage' => 86400, 'cleanbefore' => 7200, 'it_error' => $p['safety'] == 0 ? false : ($p['safety'] == 2 ? ['fatal' => true] : [])];
$p['totaltimeout'] = $p['timeout'];
$path = it_url::get_cache_filename($p); # Must be before changing cachedir below
$p['cachedir'] = it_url::get_cache_dir($p);
- if (!$p['id'])
- it::error("calling get_cache without id");
-
@mkdir($p['cachedir']);
@mkdir(dirname($path));