Commit 208290f9 authored by catch's avatar catch
Browse files

performance: #3566156 APCu FileCache can consume a ton of memory due to...

performance: #3566156 APCu FileCache can consume a ton of memory due to caching procedural hook data since Drupal 11.1

By: bkosborne
By: nicxvan
By: godotislate
By: catch
(cherry picked from commit b1922c12)
parent 77e0b6a2
Loading
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -451,7 +451,11 @@ protected static function getModuleListPattern(array $module_list): string {
   */
  protected function collectModuleHookImplementations($dir, $module, $current_module_preg, $all_modules_preg, bool $skip_procedural): void {
    $hook_file_cache = FileCacheFactory::get('hook_implementations');
    $procedural_hook_file_cache = FileCacheFactory::get('procedural_hook_implementations:' . $all_modules_preg);
    // List of modules must be included in the cache key to ensure rediscovery
    // takes place when a new module is installed. Some modules define hooks
    // on behalf of other modules and those hooks need to be found.
    // Hash to prevent massive key sizes.
    $procedural_hook_file_cache = FileCacheFactory::get('procedural_hook_implementations:' . hash('xxh3', $all_modules_preg));

    $iterator = new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS | \FilesystemIterator::FOLLOW_SYMLINKS);
    $iterator = new \RecursiveCallbackFilterIterator($iterator, static::filterIterator(...));