Skip to content
Snippets Groups Projects
Verified Commit bcee82d6 authored by Dave Long's avatar Dave Long
Browse files

Revert "Issue #3478621 by catch, longwave, nicxvan: Add filecache to OOP hook attribute parsing"

This reverts commit f6f705f8.
parent f6f705f8
No related branches found
No related tags found
20 merge requests!11380Issue #3490698 by catch, spokje: Bump MINIMUM_STABILITY back to 'stable' when...,!11239Issue #3507548: Allow workspace changes listing to show all items, without a pager,!11238Fix issue #3051797,!11213Issue #3506743 by tomislav.matokovic: Increasing the color contrast for the navigation block title against the background of the navigation sidebar to at least 4.5:1,!11147Draft: Try to avoid manually setting required cache contexts,!11108Issue #3490298 by nicxvan: Profiles can be missed in OOP hooks,!11093Drupal on MongoDB 11.1.x,!11017Issue #3502540: Add date filter for moderated content.,!11009Issue #3486972 migrate feed icon,!10999Cleaning up Taxonomy hooks and updating baseline.,!10977Issue #3501457: Fix path used in a A11y Test Admin,!10881Issue #3489329 by mfb, casey: symfony/http-foundation commit 32310ff breaks PathValidator,!10570Issue #3494197: Convert Twig engine hooks,!10567Issue #3494154: Index is not added if entity doesn't support revisions,!10548Revert "Issue #3478621 by catch, longwave, nicxvan: Add filecache to OOP hook attribute parsing",!10404Margin has been added,!10391Issue #3485117 by nexusnovaz, godotislate, nicxvan: Fix return type on...,!10388Issue #3485117 by nexusnovaz, godotislate, nicxvan: Fix return type on...,!10376Issue #3485117 by nexusnovaz, godotislate, nicxvan: Fix return type on...,!10237Issue #3484105 by nicxvan, godotislate: Automatically included .inc files are no longer included
Pipeline #340031 passed
Pipeline: drupal

#340032

    ......@@ -6,11 +6,9 @@
    use Drupal\Component\Annotation\Doctrine\StaticReflectionParser;
    use Drupal\Component\Annotation\Reflection\MockFileFinder;
    use Drupal\Component\FileCache\FileCacheFactory;
    use Drupal\Core\Extension\ProceduralCall;
    use Drupal\Core\Hook\Attribute\Hook;
    use Drupal\Core\Hook\Attribute\LegacyHook;
    use Drupal\Core\Site\Settings;
    use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
    use Symfony\Component\DependencyInjection\ContainerBuilder;
    ......@@ -158,11 +156,6 @@ public static function collectAllHookImplementations(array $module_filenames): s
    * @return void
    */
    protected function collectModuleHookImplementations($dir, $module, $module_preg): void {
    // Add the deployment identifier to the cache namespace so that changes in
    // the implementation of attribute parsing will not result in a stale
    // cache.
    $file_cache = FileCacheFactory::get('hook_implementations' . ':' . Settings::get('deployment_identifier'));
    $iterator = new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS | \FilesystemIterator::FOLLOW_SYMLINKS);
    $iterator = new \RecursiveCallbackFilterIterator($iterator, static::filterIterator(...));
    $iterator = new \RecursiveIteratorIterator($iterator);
    ......@@ -170,53 +163,32 @@ protected function collectModuleHookImplementations($dir, $module, $module_preg)
    foreach ($iterator as $fileinfo) {
    assert($fileinfo instanceof \SplFileInfo);
    $extension = $fileinfo->getExtension();
    $filename = $fileinfo->getPathname();
    $cached = $file_cache->get($filename);
    if ($extension === 'module' && !$iterator->getDepth()) {
    // There is an expectation for all modules to be loaded. However,
    // .module files are not supposed to be in subdirectories.
    include_once $filename;
    include_once $fileinfo->getPathname();
    }
    if ($extension === 'php') {
    if ($cached) {
    $class = $cached['class'];
    $attributes = $cached['attributes'];
    }
    else {
    $namespace = preg_replace('#^src/#', "Drupal/$module/", $iterator->getSubPath());
    $class = $namespace . '/' . $fileinfo->getBasename('.php');
    $class = str_replace('/', '\\', $class);
    $attributes = static::getHookAttributesInClass($class);
    $file_cache->set($filename, ['class' => $class, 'attributes' => $attributes]);
    }
    foreach ($attributes as $attribute) {
    $namespace = preg_replace('#^src/#', "Drupal/$module/", $iterator->getSubPath());
    $class = $namespace . '/' . $fileinfo->getBasename('.php');
    $class = str_replace('/', '\\', $class);
    foreach (static::getHookAttributesInClass($class) as $attribute) {
    $this->addFromAttribute($attribute, $class, $module);
    }
    }
    else {
    if ($cached) {
    $implementations = $cached;
    }
    else {
    $finder = MockFileFinder::create($filename);
    $parser = new StaticReflectionParser('', $finder);
    $implementations = [];
    foreach ($parser->getMethodAttributes() as $function => $attributes) {
    if (!StaticReflectionParser::hasAttribute($attributes, LegacyHook::class) && preg_match($module_preg, $function, $matches)) {
    $implementations[] = ['function' => $function, 'module' => $matches['module'], 'hook' => $matches['hook']];
    }
    $finder = MockFileFinder::create($fileinfo->getPathName());
    $parser = new StaticReflectionParser('', $finder);
    foreach ($parser->getMethodAttributes() as $function => $attributes) {
    if (!StaticReflectionParser::hasAttribute($attributes, LegacyHook::class) && preg_match($module_preg, $function, $matches)) {
    $this->addProceduralImplementation($fileinfo, $matches['hook'], $matches['module'], $matches['function']);
    }
    $file_cache->set($filename, $implementations);
    }
    foreach ($implementations as $implementation) {
    $this->addProceduralImplementation($fileinfo, $implementation['hook'], $implementation['module'], $implementation['function']);
    }
    }
    if ($extension === 'inc') {
    $parts = explode('.', $fileinfo->getFilename());
    if (count($parts) === 3 && $parts[0] === $module) {
    $this->groupIncludes[$parts[1]][] = $filename;
    $this->groupIncludes[$parts[1]][] = $fileinfo->getPathname();
    }
    }
    }
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment