if you put a menu like:
<?php
// 1. Establish a requestToken.
// 2. Direct user to Service Provider.
$items['linkedin/authenticate'] = array(
'title' => t('LinkedIn Login'),
'page callback' => 'linkedin_authentication_page',
'page arguments' => array(_linkedin_request_token()),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
'file' => 'linkedin.inc',
);
?>
and your function _linkedin_request_token() is in the linkedin.inc file, it fails because the file is not yet loaded. Actually the file is loaded after built up arguments and access checking, it would make sense to load the file prior to any checking so we can organize well our functions instead of putting everything in the module; Does it ?
Comments
Comment #1
sylvain lecoy commentedThis is my work around :
in the same file
linkedin.moduleBut then the
'file' => 'linkedin.inc'can be removed. And this can be confusing for other developers.Comment #2
cyberwolf commentedSubscribing.
Comment #3
sylvain lecoy commentedStill the same problem in D7 it seems.
Comment #4
crifi commentedClosed a duplicate at #1130892: _menu_item_localize execution order bug.. Similar issues:
#436940: _menu_check_access() cannot call access callback functions within include files.
#1138352: hook_menu access callback does not respect the file paramter
#337907: access callback not loaded dynamically.
Comment #5
marcingy commentedBugs are fixed in latest version first
Comment #6
sunThe defined file not only has to be loaded before attempting to do any router item processing (so that argument loader functions, access callbacks, etc are actually defined before trying to invoke them).
The router (re)building process also has to be adjusted, since it contains explicit checks for defined _to_arg() and _load() argument callbacks.
This bugged me since like forever, and I just stumbled over the problem again in #951298: Make /batch use proper response objects - for which I'm trying to make system_menu() register everything for Batch API callbacks in includes/batch.inc, but none of that works, since the router does not account for the include file definition at all.
Attached patch fixes the issue.
Comment #7
sun#6: drupal8.menu-router-include-file.6.patch queued for re-testing.
Comment #9
sunThis code path no longer exists in D8, since
hook_menu()has been removed.