This is best practice for all Drupal modules.
The two hooks provided by Content Access are:
hook_user_acl($settings)hook_per_node($settings, $node)
As noted in #2581121-4: $node not passed as argument in "per_node" hook, these really should be renamed, because they are very generic. It has been standard practice since Drupal 7 to name hooks using the module's machine name as a prefix, that way namespace conflicts are unlikely (Hooks are in a flat namespace.) Real example: early in D7 two major modules both defined hook_date(), and many sites started to have errors. Once the hooks were renamed to conform to hook_<modulename>_date(), the problems went away.
I suggest the following:
hook_content_access_user_acl($settings)hook_content_access_per_node($settings, $node)
These names are not only more descriptive but will protect us from namespace conflicts. For backwards compatibility, we can keep the old hooks but @deprecate them for removal in Content Access 8.x-2.x.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 3226834-7.patch | 974 bytes | sourabhjain |
Issue fork content_access-3226834
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
Comment #2
sourabhjain.
Comment #3
sourabhjainComment #4
gisleSounds sensible.
Comment #5
gisleNeed some more information. Sounded trivial to rename these, but I am not even able to locate them.
Comment #6
tr commentedA module defines a hook by (hopefully) documenting that hook then using the hook - i.e. calling ModuleHandler::invokeAll() and collecting the results. So search the codebase for invokeAll and you will find the two hooks.
Comment #7
sourabhjainUpdated the hooks name. Please review.
Comment #8
tr commentedThat's a good start but the old hooks need to be properly deprecated. See https://www.drupal.org/about/core/policies/core-change-policies/drupal-c...
Comment #9
gisleWe need #3226837: Document this module's hooks in content_access.api.php sorted out first, to document the depreciation.
Comment #10
gisleAll feature requests go into the most recent branch.
Postponing until #3226837: Document this module's hooks in content_access.api.php is fixed.
Comment #11
steven jones commentedWe can do this now.
Comment #15
steven jones commentedRe-worked the code in a proper MR, and created the change record: https://www.drupal.org/node/3586991
Will merge and publish shortly.
Comment #16
steven jones commentedAdded to the merge train then.