When you set up a menu callback, if you enter the wildcard at first argument (to delegate authentication to a module for instance):

  $items['%/authenticate'] = array(
    'page callback' => 'oauth_delegate',
    'page arguments' => array(0, 1),
    'access callback' => 'oauth_implements',
    'access arguments' => array(0),
    'type' => MENU_CALLBACK,
    'file' => 'oauth.inc',
* Check if a module implementing oauth exists.
function oauth_implements($module) {
  return function_exists($module . '_oauth_info');

Then it doesn't work. The function leads to 404 Page not found and the menu router doesn't even visit the access callback.

To fix the problem i added a fixed first argument:

  $items['oauth/%/authenticate'] = array(
    'page callback' => 'oauth_delegate',
    'page arguments' => array(1, 2),
    'access callback' => 'oauth_implements',
    'access arguments' => array(1),
    'type' => MENU_CALLBACK,
    'file' => 'oauth.inc',

But for patterns like delegation, i.e. OAuth based authentication where module implements and instantiate the protocol, it is nice for a user perspective to have urls like:


#11 menu-wildcards-1087940-11.patch716 bytesrocket_nova
PASSED: [[SimpleTest]]: [MySQL] 34,012 pass(es).
[ View ]
#3 docs_1087940.patch738 bytesdrewish
PASSED: [[SimpleTest]]: [MySQL] 31,535 pass(es).
[ View ]


Status:Active» Closed (works as designed)

This is by design.

Component:menu system» documentation
Status:Closed (works as designed)» Active

I probably missed something in the doc telling that we can't use a wildcard as first parameters.

Then it should be updated if not.

Version:7.x-dev» 8.x-dev
Status:Active» Needs review
new738 bytes
PASSED: [[SimpleTest]]: [MySQL] 31,535 pass(es).
[ View ]

Is this sufficient?

Yes it is :-)

Sorry when i rewrite my sentence it sounds a bit unmannered but it was not the purpose I just wrote it without re-reading after. Do you know if there is any plans to make the wildcard working as first component ? It has some use cases where it may be useful.

Version:8.x-dev» 7.x-dev
Priority:Major» Normal
Status:Needs review» Reviewed & tested by the community

Sylvain: it won't be changed in D7 -- you can file a feature request for d8 to ask for it there. The patch looks good to me, and should probably be applied to d7 and d8 at least for now.

Version:7.x-dev» 8.x-dev

Needs to go to d8 and then d7

Title:Wildcard % doesn't work as first argument in menu pathsDocument that wildcard % doesn't work as first argument in menu paths
Issue tags:+needs backport to D7

Status:Reviewed & tested by the community» Needs review

Reading the rest of the docs at http://api.drupal.org/api/drupal/modules--system--system.api.php/functio..., I actually think this note probably would read better right after this sentence, where we show the first example about wildcards:

"When path 'my-module/foo/edit' is requested, integer 1 will be replaced with 'foo' and passed to the callback function."

What say you?

Status:Needs review» Needs work

No, actually this isn't about integer substitution, it's about wildcards in the path string, which is different. So it's in the right place.

To clarify this, I suggest the additional line be:

Note that wildcards may not be used as the first component in the path you are defining.

Ooops, my mistake. Yes, up farther in that paragraph would be a better placement.

Assigned:Unassigned» rocket_nova
Status:Needs work» Needs review
new716 bytes
PASSED: [[SimpleTest]]: [MySQL] 34,012 pass(es).
[ View ]

Re-roll patch from #3 with @webchick's suggestion in #8.

Status:Needs review» Reviewed & tested by the community

Looks good, thanks!

The design was that % wouldnt work. file a feature req for %/authenticate. The docs patch is ok for now.

Status:Reviewed & tested by the community» Fixed

Committed to 7.x and 8.x. Thanks.

Status:Fixed» Closed (fixed)
Issue tags:-needs backport to D7

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