Rename hooks to include 'content_access' prefix

Created on 5 August 2021, over 3 years ago
Updated 28 April 2023, almost 2 years ago

This is best practice for all Drupal modules.

The two hooks provided by Content Access are:

  1. hook_user_acl($settings)
  2. 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:

  1. hook_content_access_user_acl($settings)
  2. 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.

✨ Feature request
Status

Postponed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024