Skip to content

Commit

Permalink
Autoloader: fix cache handling (#4506)
Browse files Browse the repository at this point in the history
  • Loading branch information
gharlan committed Feb 27, 2021
1 parent e430740 commit 4ad304d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions redaxo/src/core/functions/function_rex_other.php
Expand Up @@ -23,6 +23,7 @@ function rex_delete_cache()
->ignoreSystemStuff(false);
rex_dir::deleteIterator($finder);

rex_autoload::removeCache();
rex_clang::reset();

if (function_exists('opcache_reset')) {
Expand Down
9 changes: 7 additions & 2 deletions redaxo/src/core/lib/autoload.php
Expand Up @@ -29,6 +29,10 @@ class rex_autoload
* @var bool
*/
protected static $cacheChanged = false;
/**
* @var bool remember the cache was deleted, to make sure we don't generate a stale cache file
*/
protected static $cacheDeleted = false;
/**
* @var bool
*/
Expand Down Expand Up @@ -162,7 +166,7 @@ private static function loadCache()
*/
public static function saveCache()
{
if (!self::$cacheChanged) {
if (!self::$cacheChanged || self::$cacheDeleted) {
return;
}

Expand Down Expand Up @@ -209,6 +213,7 @@ public static function reload($force = false)
public static function removeCache()
{
rex_file::delete(self::$cacheFile);
self::$cacheDeleted = true;
}

/**
Expand All @@ -226,7 +231,6 @@ public static function addDirectory($dir)
self::$addedDirs[] = $dir;
if (!isset(self::$dirs[$dir])) {
self::_addDirectory($dir);
self::$cacheChanged = true;
}
}

Expand All @@ -253,6 +257,7 @@ private static function _addDirectory($dir)

if (!isset(self::$dirs[$dir])) {
self::$dirs[$dir] = [];
self::$cacheChanged = true;
}
$files = self::$dirs[$dir];
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirPath, RecursiveDirectoryIterator::SKIP_DOTS));
Expand Down

0 comments on commit 4ad304d

Please sign in to comment.