svn: /pear/packages/Cache_Lite/trunk/ Lite.php tests/pearbug18328.phpt
| From: | Markus Tacker | Date: | Wed, 02 Mar 2011 11:01:42 +0000 |
| Subject: | svn: /pear/packages/Cache_Lite/trunk/ Lite.php tests/pearbug18328.phpt | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-61332@lists.php.net to get a copy of this message | ||
tacker Wed, 02 Mar 2011 11:01:42 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=308851
Log:
If sys_get_temp_dir() is available and the 'cacheDir' option is not provided in the
constructor options array its output is used to determine the suitable temporary directory.
Fixes PEAR bug #18328
Bug: http://pear.php.net/bugs/18328 (unknown)
Changed paths:
U pear/packages/Cache_Lite/trunk/Lite.php
A pear/packages/Cache_Lite/trunk/tests/pearbug18328.phpt
Modified: pear/packages/Cache_Lite/trunk/Lite.php
===================================================================
--- pear/packages/Cache_Lite/trunk/Lite.php 2011-03-02 10:46:07 UTC (rev 308850)
+++ pear/packages/Cache_Lite/trunk/Lite.php 2011-03-02 11:01:42 UTC (rev 308851)
@@ -273,6 +273,14 @@
* 'hashedDirectoryUmask' => umask for hashed directory structure (int),
* 'errorHandlingAPIBreak' => API break for better error handling ? (boolean)
* );
+ *
+ * If sys_get_temp_dir() is available and the
+ * 'cacheDir' option is not provided in the
+ * constructor options array its output is used
+ * to determine the suitable temporary directory.
+ *
+ * @see http://de.php.net/sys_get_temp_dir
+ * @see http://pear.php.net/bugs/bug.php?id=18328
*
* @param array $options options
* @access public
@@ -282,6 +290,9 @@
foreach($options as $key => $value) {
$this->setOption($key, $value);
}
+ if (!isset($options['cacheDir']) &&
function_exists('sys_get_temp_dir')) {
+ $this->setOption('cacheDir', sys_get_temp_dir() . DIRECTORY_SEPARATOR);
+ }
}
/**
Added: pear/packages/Cache_Lite/trunk/tests/pearbug18328.phpt
===================================================================
--- pear/packages/Cache_Lite/trunk/tests/pearbug18328.phpt (rev 0)
+++ pear/packages/Cache_Lite/trunk/tests/pearbug18328.phpt 2011-03-02 11:01:42 UTC (rev 308851)
@@ -0,0 +1,23 @@
+--TEST--
+Cache_Lite::Cache_Lite (PEAR bug #18328)
+--FILE--
+<?php
+
+/**
+ * Process for test pearbug18328
+ *
+ * @see https://pear.php.net/bugs/bug.php?id=18328
+ * @author Markus Tacker <tacker@php.net>
+ */
+
+require_once 'Cache/Lite.php';
+$c = new Cache_Lite(array('cacheDir' => '.', 'lifeTime' =>
60,));
+var_dump($c->_cacheDir === '.');
+$c = new Cache_Lite(array('lifeTime' => 60));
+var_dump($c->_cacheDir === (function_exists('sys_get_temp_dir') ? sys_get_temp_dir() .
DIRECTORY_SEPARATOR : '/tmp/'));
+
+--GET--
+--POST--
+--EXPECT--
+bool(true)
+bool(true)
\ No newline at end of file