Better hook_menu() implementation

Scott Reynolds - October 8, 2009 - 21:26
Project:Smackdown
Version:6.x-1.x-dev
Component:Code
Category:task
Priority:normal
Assigned:Scott Reynolds
Status:closed
Description

This here uses a menu loader to verify that its a smackdown node and then passes the access check to the user_access callback.

This makes it so people can menu_alter() this cleanly. And it makes life simpler...

AttachmentSize
smackdown_menu.patch1.45 KB

#1

Scott Reynolds - October 8, 2009 - 21:28

doh ! wrong version of the patch. tab root isn't needed here. though its an interesting and important and undocumented part of hook_menu() the menu system will figure out the right root.

AttachmentSize
smackdown_menu.patch 1.42 KB

#2

Scott Reynolds - October 8, 2009 - 21:33

I still spoke to soon. Instead we can use node_access('view', $node); And this totally works because the object handed to node_access() is a 'node'. Slick...

AttachmentSize
smackdown_menu.patch 1.59 KB

#3

Scott Reynolds - October 8, 2009 - 21:35

... I failed to motivate this patch completly.

The reason to use a load function over an access function is really simple. If a user types in node/123/voting-results and 123 is not a smackdown node, what is the header you want sent. Access Denied or Page Not Found.

The load function will get you Page Not Found, which is what we want here.

#4

sirkitree - October 23, 2009 - 16:41
Status:needs review» fixed

committed http://drupal.org/cvs?commit=278840

#5

System Message - November 6, 2009 - 16:50
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.