The following hooks have gone missing in redirect.api.php:

hook_redirect_access()

Looks like we should try to remove hook_redirect_prepare() and hook_redirect_validate() as well in favor of the entity validation API.

Issue fork redirect-2702391

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

Dave Reid created an issue. See original summary.

berdir’s picture

What would access do exactly? The standard access operations are called for all entity types (edit, delete) and core doesn't document them anymore for each entity type.

And prepare/validate are no longer called, just documentation left-overs.

johnhanley’s picture

I'm trying to use hook_redirect_alter in Redirect 8, but it doesn't appear to be firing.

I want to show a message (via drupal_set_message) to alert the user of why a specific redirect has occurred.

/**
 * Implements hook_redirect_alter().
 */
function custom_redirect_alter($redirect) {
  // Inspect $redirect for specific path and display message.
}
rasikap’s picture

Assigned: Unassigned » rasikap
rasikap’s picture

Assigned: rasikap » Unassigned
Status: Active » Needs review
StatusFileSize
new1.5 KB

I have removed the hooks hook_redirect_prepare() and hook_redirect_validate() and their documentation.

berdir’s picture

Status: Needs review » Needs work
Issue tags: -beta blocker

Thanks. I'm not quite sure what to do about the remaining hooks, IMHO the load hook can be removed as well as the whole block about storage hooks, since that is all generic now.

hook_redirect_load_by_source_alter() also doesn't exist, we should probably remove that as well, if someone needs a feature like that then we can think about adding it, not sure I see the use case right now.

And altering redirects can be done with a response subscriber, redirects can be identified through the X-Redirect-ID header. Maybe we can just document that a bit?

prashant.c’s picture

Status: Needs work » Needs review
StatusFileSize
new2.96 KB
new3.49 KB

@Berdir

As per your comment i haved kept only one hook hook_redirect_alter.

Status: Needs review » Needs work

The last submitted patch, 7: 2702391-7.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

kenorb’s picture

ipo4ka704’s picture

StatusFileSize
new3.4 KB

Hi @Berdir @prashantc

After years patch is not apply, I just recreated patch.

ipo4ka704’s picture

Status: Needs work » Needs review

ysamoylenko made their first commit to this issue’s fork.

jjtoyas’s picture

The last patch seems to work.

igork96’s picture

Status: Needs review » Reviewed & tested by the community

The patch is applied successfully and it removes the hooks. Marking it as RTC.

kristen pol’s picture

Assigned: Unassigned » kristen pol

Assigning to myself as I'm triaging all RTBC issues.

kristen pol’s picture

Status: Reviewed & tested by the community » Needs work

Thanks, everyone, for the issue, patches, review, and testing.

In #10, the automated testing failed for Drupal 9.2 and PHP 7.3 so moving back to needs work while I take a look:

https://www.drupal.org/pift-ci-job/1997060

kristen pol’s picture

Title: Hooks missing? » Remove unnecessary or unused redirect hooks
Issue tags: +Needs issue summary update

Also tagging for better summary.

kristen pol’s picture

There are a few hooks that were removed from the code, but not removed from comments.

 /**
  * @} End of "addtogroup hooks".
  */
diff --git a/redirect.module b/redirect.module
index 42371af..6b3e87d 100644
--- a/redirect.module
+++ b/redirect.module
@@ -19,15 +19,6 @@ use Symfony\Component\Routing\Exception\RouteNotFoundException;
  */
 function redirect_hook_info() {
   $hooks = [
-    'redirect_load',
-    'redirect_load_by_source_alter',
-    'redirect_access',
-    'redirect_prepare',
-    'redirect_validate',
-    'redirect_presave',
-    'redirect_insert',
-    'redirect_update',
-    'redirect_delete',
     'redirect_alter',
     'redirect_response',
   ];
Kristens-MacBook-Pro:redirect kristenpol$ 
Kristens-MacBook-Pro:redirect kristenpol$ grep -r "_redirect_load" .
./redirect.api.php: *   - hook_redirect_load() (all)
Kristens-MacBook-Pro:redirect kristenpol$ grep -r "_redirect_load_by_source_alter" .
Kristens-MacBook-Pro:redirect kristenpol$ grep -r "_redirect_access" .
Kristens-MacBook-Pro:redirect kristenpol$ grep -r "_redirect_prepare" .
Kristens-MacBook-Pro:redirect kristenpol$ grep -r "_redirect_validate" .
Kristens-MacBook-Pro:redirect kristenpol$ grep -r "_redirect_presave" .
./redirect.api.php: *   - hook_redirect_presave() (all)
./redirect.api.php: *   - hook_redirect_presave() (all)
./modules/redirect_404/redirect_404.module:function redirect_404_redirect_presave(Redirect $redirect) {
Kristens-MacBook-Pro:redirect kristenpol$ grep -r "_redirect_insert" .
./redirect.api.php: *   - hook_redirect_insert() (all)
Kristens-MacBook-Pro:redirect kristenpol$ grep -r "_redirect_update" .
./redirect.api.php: *   - hook_redirect_update() (all)
Kristens-MacBook-Pro:redirect kristenpol$ grep -r "_redirect_delete" .
./redirect.api.php: *   - hook_redirect_delete() (all)
Kristens-MacBook-Pro:redirect kristenpol$ 
kristen pol’s picture

Assigned: kristen pol » Unassigned

Unassigning from me. See comments above.