Clean up hook implementations in the Taxonomy module

Created on 24 January 2025, 2 months ago

Problem/Motivation

Hooks should be updated to match grouping standards in [meta] Standardize and clean up hook classes in core πŸ“Œ [meta] Clean up hook classes in core Active .

Steps to reproduce

n/a

Proposed resolution

Split out the TaxonomyHooks class, making theme and help new single hook classes, and entity actions a new grouped hook class.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Active

Version

11.1 πŸ”₯

Component

taxonomy.module

Created by

πŸ‡ΊπŸ‡ΈUnited States mcgovernm North Carolina

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @mcgovernm
  • Pipeline finished with Success
    2 months ago
    Total: 652s
    #405007
  • Pipeline finished with Success
    2 months ago
    Total: 1305s
    #405046
  • πŸ‡ΊπŸ‡ΈUnited States mcgovernm North Carolina
  • πŸ‡¬πŸ‡§United Kingdom oily Greater London
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    @oily, please make sure when you're editing the issue summary you're reviewing what is actually needed, there are definitely remaining tasks for this issue, they are just not added yet.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    @mcgovernm this is a great first step!

    I think there are a couple of things we want to do in these that we wouldn't normally do for organization since they are hooks.

    1. Add the appropriate return types for the methods if they do not exist.
    2. Add dependency injection.

    These are autowired, in case you are not familiar with in general it means you should be able to just add a use statement for the interface of the service you need, then add that service to the constructor.

    Let me know if you have any questions!

    I'll take a deeper look later.

  • Pipeline finished with Failed
    2 months ago
    #405079
  • Pipeline finished with Failed
    2 months ago
    Total: 164s
    #405103
  • πŸ‡³πŸ‡ΏNew Zealand quietone
  • πŸ‡ΊπŸ‡ΈUnited States mcgovernm North Carolina
  • Pipeline finished with Success
    2 months ago
    Total: 648s
    #405109
  • πŸ‡¬πŸ‡§United Kingdom oily Greater London

    @nicxvan wrt #5

    @oily, please make sure when you're editing the issue summary you're reviewing what is actually needed, there are definitely remaining tasks for this issue, they are just not added yet.

    I did not edit 'Remaining tasks'. It is blank. If you are referring to the other fields, I filled them based on what I thought appropriate. 'None' could be thought of as 'None' ever or 'None' just now.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    You did add none to remaining tasks, I removed it in comment 5.

    You did the same in this issue here too: πŸ“Œ Drupal\Core\Theme\ComponentNegotiator::negotiate uses a lot of memory Active

    I agree keeping issue summaries up to date is useful, I'm not trying to discourage you from updating them.

    I am trying to encourage you to review the actual issue and provide relevant updates.

    There are remaining tasks both in this issue and the other, no need to write them or if you don't know what they are, but none is not accurate.

  • πŸ‡¬πŸ‡§United Kingdom oily Greater London

    @nicxvan RE: #10 I did not realise you had had to redo. I dont want to create work for others. So I agree, I will be more circumspect about completing issue summaries.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    taxonomy_theme_suggestions_taxonomy_term can be manually converted, the rector rule missed all theme suggestions.

  • Pipeline finished with Running
    2 months ago
    Total: 1300s
    #405885
  • Pipeline finished with Failed
    2 months ago
    Total: 520s
    #407584
  • Pipeline finished with Failed
    2 months ago
    Total: 4370s
    #407582
  • Pipeline finished with Failed
    2 months ago
    Total: 487s
    #408515
  • Pipeline finished with Failed
    2 months ago
    Total: 467s
    #409408
  • πŸ‡ΊπŸ‡ΈUnited States mcgovernm North Carolina

    Tests started failing after adding the return type to hook_help in this commit. I have not been able to figure out why this would change anything.

    Time: 00:37.972, Memory: 4.00 MB
    
    There was 1 failure:
    
    1) Drupal\Tests\navigation\FunctionalJavascript\PerformanceTest::testLogin
    Failed asserting that 61 is identical to 60.
    
    /var/www/html/core/modules/navigation/tests/src/FunctionalJavascript/PerformanceTest.php:75

    Line 75 of PerformanceTest.php:
    $this->assertSame(60, $performance_data->getCacheGetCount());

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    I wouldn't worry about it, unless you think this is ready for review at the moment. It's most likely an upstream change affecting that and will be fixed separately.

    When I see these I usually try to track down the issue that introduced it, and open an issue to resolve it, but that's not strictly necessary if you're still working on other feedback on the issue.

  • Pipeline finished with Failed
    2 months ago
    Total: 191s
    #409707
  • Pipeline finished with Failed
    2 months ago
    Total: 158s
    #409710
  • Pipeline finished with Failed
    2 months ago
    Total: 1159s
    #409715
  • Pipeline finished with Failed
    2 months ago
    Total: 625s
    #411450
  • Pipeline finished with Failed
    2 months ago
    Total: 471s
    #411463
  • Pipeline finished with Failed
    2 months ago
    Total: 637s
    #411496
  • πŸ‡ΊπŸ‡ΈUnited States mcgovernm North Carolina

    mcgovernm β†’ changed the visibility of the branch drupal-3502014-3502014-clean-up-hook to hidden.

  • Pipeline finished with Failed
    about 2 months ago
    Total: 136s
    #416981
  • Pipeline finished with Failed
    about 2 months ago
    Total: 214s
    #416995
  • Pipeline finished with Failed
    about 2 months ago
    Total: 135s
    #417049
  • Pipeline finished with Failed
    about 2 months ago
    Total: 469s
    #417057
  • Pipeline finished with Failed
    about 2 months ago
    Total: 533s
    #417070
  • Pipeline finished with Failed
    about 2 months ago
    Total: 575s
    #417181
  • Pipeline finished with Failed
    about 2 months ago
    Total: 462s
    #417246
  • Pipeline finished with Success
    about 2 months ago
    Total: 514s
    #417935
  • Pipeline finished with Failed
    about 2 months ago
    Total: 399s
    #418273
  • Pipeline finished with Success
    about 2 months ago
    Total: 492s
    #419996
  • Pipeline finished with Failed
    about 2 months ago
    Total: 127s
    #420223
  • Pipeline finished with Failed
    about 2 months ago
    Total: 417s
    #420227
  • Pipeline finished with Success
    about 2 months ago
    Total: 808s
    #420236
  • Pipeline finished with Failed
    about 2 months ago
    Total: 503s
    #420257
  • Pipeline finished with Failed
    about 1 month ago
    Total: 257s
    #434699
  • Pipeline finished with Failed
    about 1 month ago
    Total: 130s
    #434895
  • Pipeline finished with Failed
    about 1 month ago
    Total: 122s
    #435004
  • Pipeline finished with Success
    about 1 month ago
    Total: 464s
    #435006
  • Pipeline finished with Failed
    about 1 month ago
    Total: 423s
    #435081
  • Pipeline finished with Success
    about 1 month ago
    Total: 438s
    #435664
  • Pipeline finished with Success
    about 1 month ago
    #435705
  • πŸ‡ΊπŸ‡ΈUnited States mcgovernm North Carolina
  • πŸ‡ΊπŸ‡ΈUnited States mcgovernm North Carolina

    Putting back to needs work, as taxonomy_theme_suggestions_taxonomy_term still needs to be addressed.

  • πŸ‡ΊπŸ‡ΈUnited States mcgovernm North Carolina
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Sorry which branch? Can you hide the ones you're not using?

  • πŸ‡ΊπŸ‡ΈUnited States mcgovernm North Carolina

    mcgovernm β†’ changed the visibility of the branch 3502014-clean-up-hook to hidden.

  • πŸ‡ΊπŸ‡ΈUnited States mcgovernm North Carolina

    mcgovernm β†’ changed the visibility of the branch 11.x to hidden.

  • Pipeline finished with Success
    about 1 month ago
    Total: 2945s
    #435825
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Looks great!

    Couple of comments, I didn't provide a lot of detail feel free to ping me on slack if you need clarification.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 215s
    #435922
  • Pipeline finished with Failed
    about 1 month ago
    Total: 579s
    #436928
  • Pipeline finished with Success
    about 1 month ago
    Total: 374s
    #436993
  • Pipeline finished with Success
    about 1 month ago
    Total: 358s
    #437043
  • Pipeline finished with Failed
    about 1 month ago
    Total: 651s
    #437237
  • πŸ‡ΊπŸ‡ΈUnited States mcgovernm North Carolina
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    I think this needs a clean rebase.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Sorry I was looking at the old MR, is this ready for review again?

  • πŸ‡ΊπŸ‡ΈUnited States mcgovernm North Carolina

    Thanks! This is ready for review again. I had moved the setting of $config to a helper function, but wasn't sure after the last couple of comments if that was necessary or if it could have been left in the constructor for this case.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Helper is good!

  • Pipeline finished with Failed
    16 days ago
    Total: 606s
    #450567
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Haven't reviewed because @nicxvan seems to be on it but love the file structure picked here.

  • Pipeline finished with Failed
    13 days ago
    Total: 167s
    #453425
  • πŸ‡ΊπŸ‡ΈUnited States mcgovernm North Carolina
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    I think this is closer, I hate to say it, I think we came up with a decent rubric for the split in the meta: #3493453-25: [meta] Standardize and clean up hook classes in core β†’

    I know you've been putting a lot towards this, but can we split the files based on the new thoughts I linked? Once that is in I think it's ready for a final review.

  • Pipeline finished with Success
    13 days ago
    Total: 606s
    #453438
  • πŸ‡ΊπŸ‡ΈUnited States mcgovernm North Carolina

    Thanks for the feedback! I think it was just two classes that needed to be renamed based on the text file, this is ready for review.

  • Pipeline finished with Success
    13 days ago
    Total: 2924s
    #453463
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Two minor comments you can merge in then I think it's ready!

  • Pipeline finished with Success
    13 days ago
    Total: 1362s
    #453504
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Great thanks!

  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    getConfig() is still broken. It does not return a Config object, it returns the ConfigFactory because the condition there is never TRUE to go inside the if condition.

    It works because it does not have a return type, which I'm not sure why phpstan doesn't complain a about.

    The tests pass because what actually happens is that it returns a new config object for the non-existing maintain_index_table config and that evaluates to true. We have no tests that disable this flag.

    drop the if, add an explicit return type, and just make it a one-liner to return that config. Since that's the only config key we care about, I'd actually suggest to rename the method to something like shouldMaintainIndexTable() and directly return a boolean from that.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Oh great catch, yes we need to do that too.

  • πŸ‡ΊπŸ‡ΈUnited States mcgovernm North Carolina

    Thank you @berdir! I've just pushed a commit to address that. I also noticed we still need to remove taxonomy_build_node_index and taxonomy_delete_node_index from taxonomy.module since they've been moved to TaxonomyEntityHooks. I should be able to get to that shortly.

  • Pipeline finished with Failed
    12 days ago
    Total: 706s
    #454143
  • Pipeline finished with Failed
    12 days ago
    Total: 227s
    #454223
  • Pipeline finished with Failed
    12 days ago
    Total: 531s
    #454225
  • Pipeline finished with Failed
    12 days ago
    Total: 345s
    #454236
  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    Unsure about the helper functions. Unlike some others, they are not underscore-prefixed nor are they hooks, so technically they are an API. in https://git.drupalcode.org/project/drupal/-/merge_requests/10999#note_45... I proposed to keep them but deprecate them for D12.

  • Pipeline finished with Success
    12 days ago
    Total: 488s
    #454250
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Yeah those need to be deprecated.

  • Pipeline finished with Failed
    12 days ago
    Total: 692s
    #454376
  • Pipeline finished with Failed
    12 days ago
    Total: 204s
    #454405
  • Pipeline finished with Failed
    12 days ago
    Total: 676s
    #454407
  • Pipeline finished with Failed
    12 days ago
    Total: 174s
    #454442
  • Pipeline finished with Failed
    12 days ago
    Total: 608s
    #454445
  • Pipeline finished with Success
    9 days ago
    Total: 618s
    #456193
  • πŸ‡ΊπŸ‡ΈUnited States mcgovernm North Carolina
  • πŸ‡ΊπŸ‡ΈUnited States mcgovernm North Carolina
  • Pipeline finished with Canceled
    7 days ago
    Total: 390s
    #458071
  • Pipeline finished with Failed
    7 days ago
    Total: 481s
    #458081
  • Pipeline finished with Success
    7 days ago
    #458093
  • Status changed to Needs review 7 days ago
  • πŸ‡ΊπŸ‡ΈUnited States mcgovernm North Carolina
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Two minor comments! Getting pretty close again

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Made suggestions for all of the things that need tweaking I think.

  • Pipeline finished with Failed
    6 days ago
    Total: 128s
    #458634
  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    FWIW, I specifically suggested to not introduce a helper service for the node indexing and keep them as protected functions. It's not an API that taxonomy module offers, so it makes more sense to me as protected methods. Yes, the logic is duplicated then on the functions, but I don't think there is a rule against that.

  • Pipeline finished with Success
    6 days ago
    Total: 703s
    #458640
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Did you mean in a comment on the MR? I don't see that recommendation in these comments.

  • Pipeline finished with Success
    6 days ago
    Total: 539s
    #458746
  • πŸ‡ΊπŸ‡ΈUnited States mcgovernm North Carolina

    Thank you @berdir. I've created a new branch and on it rolled back the commit that moved it to a service. New draft MR is here. Hopefully I've deprecated these correctly, I assume we'll need to update the CR to indicate these have been moved to protected methods?

    Diff between new and current MR

  • πŸ‡ΊπŸ‡ΈUnited States mcgovernm North Carolina
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    nicxvan β†’ changed the visibility of the branch 3502014-EntityHooks to hidden.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    I updated the CR and hid the other approach, I think this looks good but I want to give @berdir a chance to look.

Production build 0.71.5 2024