Skip to content

Commit

Permalink
MDL-65761 lib: Update scssphp to 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocolate-lightning committed Jul 16, 2019
1 parent f619e30 commit d7b43fd
Show file tree
Hide file tree
Showing 9 changed files with 839 additions and 348 deletions.
16 changes: 8 additions & 8 deletions lib/scssphp/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/
class Cache
{
const CACHE_VERSION = 0;
const CACHE_VERSION = 1;

// directory used for storing data
public static $cacheDir = false;
Expand All @@ -41,12 +41,12 @@ class Cache
public static $prefix = 'scssphp_';

// force a refresh : 'once' for refreshing the first hit on a cache only, true to never use the cache in this hit
public static $forceFefresh = false;
public static $forceRefresh = false;

// specifies the number of seconds after which data cached will be seen as 'garbage' and potentially cleaned up
public static $gcLifetime = 604800;

// array of already refreshed cache if $forceFefresh==='once'
// array of already refreshed cache if $forceRefresh==='once'
protected static $refreshed = [];

/**
Expand Down Expand Up @@ -74,7 +74,7 @@ public function __construct($options)
}

if (isset($options['forceRefresh'])) {
self::$forceFefresh = $options['force_refresh'];
self::$forceRefresh = $options['force_refresh'];
}

self::checkCacheDir();
Expand All @@ -97,13 +97,13 @@ public function getCache($operation, $what, $options = [], $lastModified = null)
{
$fileCache = self::$cacheDir . self::cacheName($operation, $what, $options);

if ((! self::$forceRefresh || (self::$forceRefresh === 'once' && isset(self::$refreshed[$fileCache])))
&& file_exists($fileCache)
if ((! self::$forceRefresh || (self::$forceRefresh === 'once' &&
isset(self::$refreshed[$fileCache]))) && file_exists($fileCache)
) {
$cacheTime = filemtime($fileCache);

if ((is_null($lastModified) || $cacheTime > $lastModified)
&& $cacheTime + self::$gcLifetime > time()
if ((is_null($lastModified) || $cacheTime > $lastModified) &&
$cacheTime + self::$gcLifetime > time()
) {
$c = file_get_contents($fileCache);
$c = unserialize($c);
Expand Down
Loading

0 comments on commit d7b43fd

Please sign in to comment.