Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Switching cache storage from serialized php to json.

  • Loading branch information...
commit 727af5a86391f2f085a4e3888a4e67fb7d440bdb 1 parent 7b1c3fc
@peteboere authored
Showing with 13 additions and 11 deletions.
  1. +13 −11 lib/IO.php
View
24 lib/IO.php
@@ -79,7 +79,7 @@ public static function testOutputDir ( $write_test = true ) {
csscrush::log( 'Permissions updated' );
}
}
-
+
if ( $error ) {
csscrush::logError( $error );
trigger_error( __METHOD__ . ": $error\n", E_USER_WARNING );
@@ -156,8 +156,7 @@ public static function validateExistingOutput () {
$options_unchanged = true;
foreach ( $existing_options as $key => &$value ) {
- if ( $existing_options->{ $key } !== $options->{ $key } ) {
- // csscrush::log( "$key is different" );
+ if ( $existing_options[ $key ] !== $options->{ $key } ) {
$options_unchanged = false;
break;
}
@@ -241,9 +240,12 @@ public static function getCacheData () {
$cache_data = array();
- if ( $cache_data_exists && $cache_data_file_is_writable ) {
- // Load from file
- $cache_data = unserialize( file_get_contents( $process->cacheFilePath ) );
+ if (
+ $cache_data_exists &&
+ $cache_data_file_is_writable &&
+ $cache_data = json_decode( file_get_contents( $process->cacheFilePath ), true )
+ ) {
+ // Successfully loaded config file.
}
else {
// Config file may exist but not be writable (may not be visible in some ftp situations?)
@@ -255,9 +257,9 @@ public static function getCacheData () {
trigger_error( __METHOD__ . ": $error\n", E_USER_NOTICE );
}
}
- // Create
+ // Create config file.
csscrush::log( 'Creating cache data file' );
- file_put_contents( $process->cacheFilePath, serialize( array() ) );
+ file_put_contents( $process->cacheFilePath, json_encode( array() ) );
}
return $cache_data;
@@ -267,12 +269,12 @@ public static function getCacheData () {
public static function saveCacheData () {
$process = csscrush::$process;
-
+
// Need to store the current path so we can check we're using the right config path later
$process->cacheData[ 'originPath' ] = $process->cacheFilePath;
-
+
csscrush::log( 'Saving config' );
- file_put_contents( $process->cacheFilePath, serialize( $process->cacheData ) );
+ file_put_contents( $process->cacheFilePath, json_encode( $process->cacheData ) );
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.