Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If I create the following menu item in hook_menu, then calling that path causes the fatal error PHP Fatal error: Exception thrown without a stack frame in Unknown on line 0
in D7 (A page not found in D6).
$items['test/%node/%test'] = array(
'title' => 'Test',
'load arguments' => array('%map', '%index'),
'description' => "Test some code here",
'page callback' => 'test_call',
'page arguments' => array(1, 2),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
This happens because node_load does not check the $revision argument that gets passed in for validity as a vid. i.e. all vid's should be numeric. I'm not sure how this might affect the node_load_multiple, but for node_load the following patches should correct the issue. At least they do for me.
Comment | File | Size | Author |
---|---|---|---|
#8 | multiple-load-arguments-367343-8.patch | 1.23 KB | cdale |
#2 | node-load-arguments-367343-2-D7.patch | 1.12 KB | cdale |
node-load-arguments-D6.patch | 771 bytes | cdale | |
node-load-arguments-D7.patch | 1.09 KB | cdale | |
Comments
Comment #2
cdale CreditAttribution: cdale commentedReroll ro remove notices.
Comment #3
cdale CreditAttribution: cdale commentedI feel this is probably critical. Feel free to correct me.
Comment #5
cdale CreditAttribution: cdale commentedComment #6
cdale CreditAttribution: cdale commentedDoes anyone else have any designs, ideas or other ways to achieve using load arguments with %node? Is this a flaw with the menu system that this can not be done? Or is the fault with node_load?
Comment #7
Damien Tournoud CreditAttribution: Damien Tournoud commentedThis should be:
Comment #8
cdale CreditAttribution: cdale commentedIs there some documentation for this somewhere that I've missed? Does this only apply when using 'load arguments'? I guess this would not be a problem if the 'load arguments' key was not there.
I think it could be useful to be able to do this, as such I've made a patch.
It allows load arguments to be defined as below:
This allows for multiple _load functions to be used, with different load arguments for each if desired. It will also work as is currently i.e the code below will still work:
Does this seem like a reasonable solution? What are peoples thoughts for allowing this? Probably not a huge demand for it, but it could be useful, and it is a minimal change to allow it, and it breaks no existing functionality that I can see.
Comment #9
cburschkaI'm not well-versed enough in the menu system to know whether this feature is needed, but this property should definitely be an array rather than numbered keys:
This also allows for a convenient is_array() check (making it backward compatible). What you lose is the option of defining the same load arguments for several placeholders, but not all. But that seems like a rare edge case where you may as well define the load arguments for each placeholder separately.
Comment #10
andypostsubscribe
Comment #11
webchickComment #12
Cyberwolf CreditAttribution: Cyberwolf commentedSubscribing.
Comment #13
casey CreditAttribution: casey commentedsubscribe
Comment #14
andypostpatch outdated, and looks like 8.1.x as feature
Comment #15
BerdirThis doesn't make sense anymore, the routing is completely different and and has no issues with multiple arguments that are upcasted.