diff --git a/library/HTMLPurifier/DefinitionCache/Serializer.php b/library/HTMLPurifier/DefinitionCache/Serializer.php
index f930c6b9..902c19c0 100644
--- a/library/HTMLPurifier/DefinitionCache/Serializer.php
+++ b/library/HTMLPurifier/DefinitionCache/Serializer.php
@@ -198,10 +198,7 @@ class HTMLPurifier_DefinitionCache_Serializer extends HTMLPurifier_DefinitionCac
if ($result !== false) {
// set permissions of the new file (no execute)
$chmod = $config->get('Cache.SerializerPermissions');
- if ($chmod === null) {
- // don't do anything
- } else {
- $chmod = $chmod & 0666;
+ if ($chmod !== null) {
chmod($file, $chmod);
}
}
@@ -229,14 +226,6 @@ class HTMLPurifier_DefinitionCache_Serializer extends HTMLPurifier_DefinitionCac
} elseif (!$this->_testPermissions($base, $chmod)) {
return false;
}
- if ($chmod === null) {
- trigger_error(
- 'Base directory ' . $base . ' does not exist,
- please create or change using %Cache.SerializerPath',
- E_USER_WARNING
- );
- return false;
- }
if ($chmod !== null) {
mkdir($directory, $chmod);
} else {
diff --git a/tests/HTMLPurifier/DefinitionCache/SerializerTest.php b/tests/HTMLPurifier/DefinitionCache/SerializerTest.php
index 57c2c3e2..cd226b34 100644
--- a/tests/HTMLPurifier/DefinitionCache/SerializerTest.php
+++ b/tests/HTMLPurifier/DefinitionCache/SerializerTest.php
@@ -23,6 +23,7 @@ class HTMLPurifier_DefinitionCache_SerializerTest extends HTMLPurifier_Definitio
$rel_file = HTMLPURIFIER_PREFIX . '/HTMLPurifier/DefinitionCache/Serializer/Test/' .
$config_md5 . '.ser'
);
+
if($file && file_exists($file)) unlink($file); // prevent previous failures from causing problems
$this->assertIdentical($config_md5, $cache->generateKey($config));
@@ -215,10 +216,12 @@ class HTMLPurifier_DefinitionCache_SerializerTest extends HTMLPurifier_Definitio
$def_original = $this->generateDefinition();
$cache->add($def_original, $config);
- $this->assertFileExist($dir . '/Test/1.0.0,serial,1.ser');
- $this->assertEqual(0600, 0777 & fileperms($dir . '/Test/1.0.0,serial,1.ser'));
- $this->assertEqual(0700, 0777 & fileperms($dir . '/Test'));
+ $file_path = $dir . '/Test/1.0.0,serial,1.ser';
+ $this->assertFileExist($file_path);
+
+ $file_permissions = substr(sprintf("%o",fileperms($file_path)),-4);;
+ $this->assertEqual("0700", $file_permissions);
unlink($dir . '/Test/1.0.0,serial,1.ser');
rmdir( $dir . '/Test');