Problem/Motivation

Marked critical because oop hooks won't get picked up for modules marked as converted.
I added a note to the cr referencing this issue.

While working on #3491275: Mark fully converted core modules as converted to OOP hooks History has no procedural hooks.

Marking history as converted

parameters:
  history.hooks_converted: true

This test fails: core/modules/history/tests/src/Kernel/Views/HistoryTimestampTest.php
We need to include .module and / inc files even if we do not scan them.

Apply this patch and run the test and it passes.

Steps to reproduce

.

Proposed resolution

Remove the directory check.
The change looks bigger than it is, it is just removing this:

// Check only hook classes.
    if ($skip_procedural) {
      $dir = $dir . '/src/Hook';
    }

and the wrapping if
if (is_dir($dir)) {

Changing the directory breaks the iterator.

We didn't see this in the original issue because the original issue only used the container parameter in one module and that module did not have hook classes.

Remaining tasks

N/A

User interface changes

N/A

Introduced terminology

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

Issue fork drupal-3491386

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

nicxvan created an issue. See original summary.

nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Title: Include .module files during HookCollection always even if not scanned » Changing $dir during hook collection breaks
nicxvan’s picture

This might be a red herring.

It was my local file cache.

nicxvan’s picture

Title: Changing $dir during hook collection breaks » Changing $dir during hook collection breaks filter iterator
Priority: Normal » Major
Issue tags: +beta target
nicxvan’s picture

Status: Active » Needs review
nicxvan’s picture

Priority: Major » Critical
Issue summary: View changes
nicxvan’s picture

nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Title: Changing $dir during hook collection breaks filter iterator » Using hooks_converted container parameter changes $dir during hook collection breaking collection of oop hooks.
nicxvan’s picture

Issue summary: View changes
catch’s picture

Status: Needs review » Reviewed & tested by the community

Oof that was my suggestion in the other issue. Feels like it should be possible to make this work - if we only have OOP hooks, we should only have to scan the hooks directory, but probably means two complete logic branches not this quick (broken) fix.

Moving to RTBC, since this is a critical regression from the previous issue, I'll commit it later if no objections.

nicxvan’s picture

Yes, we could make that work, but it definitely needs a follow up, we currently look at every single file in a module directory.

We could probably safely limit it to scan just the top level and /src/Hooks always whether you do procedural or not. That will reduce the number of iterations significantly too.

  • catch committed c3881aff on 11.1.x
    Issue #3491386 by nicxvan: Using hooks_converted container parameter...

  • catch committed f4f0b14b on 11.x
    Issue #3491386 by nicxvan: Using hooks_converted container parameter...
catch’s picture

Version: 11.x-dev » 11.1.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x and cherry-picked to 11.1.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.