Move node_mass_update_* functions to service and fix invalid hook invocation in NodeHooks

Created on 30 June 2025, about 2 months ago

Problem/Motivation

node.admin.inc is 180 lines of procedural code that should be moved to a service/class.

@berdir also found in https://www.drupal.org/project/drupal/issues/3532204#comment-16170601 πŸ“Œ Move preprocess functions into NodeThemeHooks Active that node_mass_update is being invoked as if it were a hook in NodeHooks::userCancelBlockUnpublish/userCancelReassign which needs to change as these are not hooks.

Steps to reproduce

N/A

Proposed resolution

Move all functions in node.admin.inc to a class/service
Fix documentation, including user.api.php (this should probably just change to an example rather than a concrete call)
Deprecate node_mass_update

Remaining tasks

All of it

User interface changes

N/A

Introduced terminology

N/A

API changes

node_mass_update is deprecated

Data model changes

N/A

Release notes snippet

N/A

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component

node system

Created by

πŸ‡¦πŸ‡ΊAustralia acbramley

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

Merge Requests

Comments & Activities

  • Issue created by @acbramley
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Fun fact! I first found the oddity that is node mass update here πŸ“Œ [ignore] Convert everything everywhere all at once Active which is why I knew it wasn't a hook in the first place even though it goes through through module handler invoke.

    There are not many of these types of calls left in core.

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    This is barely used in contrib, it would be nice if we could overhaul this with something more modern but maybe that could be done in follow-ups http://codcontrib.hank.vps-private.net/search?text=node_mass_update%28%2...

    Speaking internally, @larowlan suggested changing the $updates array to a static closure that takes the loaded $node and would allow us to just call API directly. I think this would be a huge improvement and would be good for a follow up.

  • Merge request !12561Issue #3533083: Move node_mass_update functions β†’ (Closed) created by acbramley
  • Pipeline finished with Failed
    about 2 months ago
    Total: 177s
    #535805
  • Pipeline finished with Failed
    about 2 months ago
    Total: 144s
    #535817
  • πŸ‡¦πŸ‡ΊAustralia acbramley

    We chatted about naming internally and landed on NodeBulkUpdate::process, the word "mass" doesn't really get used a lot in Drupal so this seemed to fit better.

    Setting to NR to get some eyes on it, agree on the naming, then I'll fix up the CR and make any further changes.

    All tests for this are in core/modules/user/tests/src/Functional/UserCancelTest.php

  • Pipeline finished with Success
    about 2 months ago
    Total: 493s
    #535820
  • Pipeline finished with Success
    about 2 months ago
    Total: 1197s
    #536581
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Any concern with removing in 12? Should it be pushed to 13?
    Seems odd the test coverage is in user should it be moved to the node module instead?
    Think process() makes sense.

    Hope that helps some.

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Bumped to D13.

    The tests could really live in either place I guess because technically it's testing user module hooks in Node module, but the test also tests the same stuff around comment so it makes sense to have them all live together in user?

  • Pipeline finished with Success
    about 1 month ago
    Total: 952s
    #543519
  • Pipeline finished with Success
    about 1 month ago
    #550815
  • Pipeline finished with Success
    about 1 month ago
    #550825
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    This looks great!

    I like the name process.
    Revision changes look good too.

    The tests should stay in user I think since that is the caller. We could always move it in a follow up.

    I did wonder if there is any reason not to move the deprecated function to node.module so we could delete the admin.inc file?

    It's not really super important so feel free to push back.

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

    I did wonder if there is any reason not to move the deprecated function to node.module so we could delete the admin.inc file?

    If we follow what we're now doing with the template_preprocess callbacks it would be to keep the file and add a @trigger_error(), as this is named admin.inc it's also blocked on the loadAllIncludes() issue then.

  • The Needs Review Queue Bot β†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • πŸ‡¦πŸ‡ΊAustralia acbramley
  • Pipeline finished with Success
    17 days ago
    #565645
  • Pipeline finished with Success
    5 days ago
    Total: 680s
    #575116
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Made a small tweak to the CR but believe this one is good to go. Don't see any open items.

    • catch β†’ committed 8395afd9 on 11.x
      Issue #3533083 by acbramley, nicxvan, smustgrave, berdir: Move...
  • πŸ‡¬πŸ‡§United Kingdom catch

    Committed/pushed to 11.x, thanks!

Production build 0.71.5 2024