Per the node module, contributed modules can implement hook_node_insert, hook_node_update, hook_node_delete, etc.

Drupal is moving in this direction of providing hook_$type_$op for more than just nodes, including for blocks and users.

It would be great for Path Redirect to do the same, by providing:

  • hook_path_redirect_insert
  • hook_path_redirect_update
  • hook_path_redirect_delete

The attached patch does that pretty simply.

Comments

Status: Needs review » Needs work

The last submitted patch, path_redirect.patch, failed testing.

sbandyopadhyay’s picture

Solving #808980: Can't use redirect paths as menu items. is easier with this API.

Not sure why the patch failed testing. I'd appreciate any help in making the patch in the right format. It's a very small, very lightweight patch.

dave reid’s picture

Version: 6.x-1.0-rc2 » 6.x-1.x-dev

Patches need to be applied to 6.x-1.x-dev.

sbandyopadhyay’s picture

Status: Needs work » Needs review
StatusFileSize
new1.07 KB

OK let's try this again...

dave reid’s picture

Status: Needs review » Needs work

Note that the hook_path_redirect_delete() won't execute in some cases as it may get passed $conditions. Better to just do:

if ($redirects = path_redirect_load_multiple($rids, $conditions)) {
  .. execute the hook for each redirect
}
sbandyopadhyay’s picture

Status: Needs work » Needs review
StatusFileSize
new1.06 KB

Yea, I missed that. Updated the patch.

dave reid’s picture

Status: Needs review » Fixed
sbandyopadhyay’s picture

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.