11 public function add($def, $config)
17 if (file_exists(
$file)) {
23 return $this->
_write(
$file, serialize($def), $config);
31 public function set($def, $config)
40 return $this->
_write(
$file, serialize($def), $config);
54 if (!file_exists(
$file)) {
60 return $this->
_write(
$file, serialize($def), $config);
67 public function get($config)
70 if (!file_exists(
$file)) {
73 return unserialize(file_get_contents(
$file));
80 public function remove($config)
83 if (!file_exists(
$file)) {
100 while (
false !== (
$filename = readdir($dh))) {
122 while (
false !== (
$filename = readdir($dh))) {
130 if ($this->
isOld($key, $config)) {
171 $base = $config->get(
'Cache.SerializerPath');
172 $base = is_null($base) ? HTMLPURIFIER_PREFIX .
'/HTMLPurifier/DefinitionCache/Serializer' : $base;
188 $chmod = $config->get(
'Cache.SerializerPermissions');
192 $chmod = $chmod & 0666;
193 chmod(
$file, $chmod);
206 $chmod = $config->get(
'Cache.SerializerPermissions');
210 if (!is_dir($directory)) {
212 if (!is_dir($base)) {
214 'Base directory ' . $base .
' does not exist, 215 please create or change using %Cache.SerializerPath',
223 mkdir($directory, $chmod);
241 if (is_writable($dir)) {
248 'Directory ' . $dir .
' does not exist',
253 if (function_exists(
'posix_getuid')) {
255 if (fileowner($dir) === posix_getuid()) {
257 $chmod = $chmod | 0700;
258 if (chmod($dir, $chmod)) {
261 } elseif (filegroup($dir) === posix_getgid()) {
262 $chmod = $chmod | 0070;
266 $chmod = $chmod | 0777;
269 'Directory ' . $dir .
' not writable, ' .
270 'please chmod to ' . decoct($chmod),
276 'Directory ' . $dir .
' not writable, ' .
277 'please alter file permissions',
generateBaseDirectoryPath($config)
Generates path to base directory that contains all definition type serials.
Abstract class representing Definition cache managers that implements useful common methods and is a ...
generateDirectoryPath($config)
Generates the path to the directory contain this cache's serial files.
checkDefType($def)
Checks if a definition's type jives with the cache's type.
_prepareDir($config)
Prepares the directory that this type stores the serials in.
_write($file, $data, $config)
Convenience wrapper function for file_put_contents.
generateFilePath($config)
Generates the file path to the serial file corresponding to the configuration and definition name...
_testPermissions($dir, $chmod)
Tests permissions on a directory and throws out friendly error messages and attempts to chmod it itse...
isOld($key, $config)
Tests whether or not a key is old with respect to the configuration's version and revision number...
generateKey($config)
Generates a unique identifier for a particular configuration.