Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Better Cache_Lite support:

- test filename must be truly random to work in multi-user environment
- test scripts must use bundled Cache_Lite code

git-svn-id: svn://dklab.ru/lib/DbSimple/trunk@172 78bb956b-1e24-0410-b8d0-c528fdc9eae3
  • Loading branch information...
commit d0bc8a7a4bcd169e4b877b913c81c939b3b6aa41 1 parent 1241a17
dk authored
Showing with 11 additions and 8 deletions.
  1. +10 −8 lib/DbSimple/Generic.php
  2. +1 −0  t/DbSimple/init.php
View
18 lib/DbSimple/Generic.php
@@ -118,22 +118,24 @@ function& connect($dsn)
if (@fopen('Cache/Lite.php', 'r', true)) {
$tmp_dirs = array(
ini_get('session.save_path'),
+ getenv("TEMP"),
+ getenv("TMP"),
+ getenv("TMPDIR"),
'/tmp'
);
- foreach($tmp_dirs as $dir) {
- $fp = @fopen($dir.'/t', 'w');
- if (is_resource($fp)) {
-
+ foreach ($tmp_dirs as $dir) {
+ if (!$dir) continue;
+ $fp = @fopen($testFile = $dir . '/DbSimple_' . md5(getmypid() . microtime()), 'w');
+ if ($fp) {
+ fclose($fp);
+ unlink($testFile);
require_once 'Cache/Lite.php';
- $t = new Cache_Lite(array('cacheDir' => $dir.'/', 'lifeTime' => null, 'automaticSerialization' => true));
+ $t =& new Cache_Lite(array('cacheDir' => $dir.'/', 'lifeTime' => null, 'automaticSerialization' => true));
$object->setCacher(&$t);
-
break;
}
}
- fclose($fp);
- unlink($dir.'/t');
}
return $object;
}
View
1  t/DbSimple/init.php
@@ -4,6 +4,7 @@
header("Content-type: text/plain");
include_once dirname(__FILE__) . "/../../lib/config.php";
+ini_set("include_path", ini_get("include_path").PATH_SEPARATOR.dirname(__FILE__).'/..'); // for Cache_Lite
include_once "DbSimple/Generic.php";
$DSN = array();

0 comments on commit d0bc8a7

Please sign in to comment.
Something went wrong with that request. Please try again.