This are the facts:
1. Menu paths (router item paths to be exact) can have a maximum depth of MENU_MAX_PARTS in Drupal 6.
2. You can specify load arguments in hook_menu that are stored with the router items as 'load_functions' to the database.

For the case that every part is dynamic we can have MENU_MAX_PARTS load arguments for a single item. The most complex case of load arguments is 'load arguments' => array('%map', '%index'). All the parameters are serialized and stored in the 'load_functions' field in table 'menu_router'. The schema definition for that field look like this:

'load_functions' => array(
 'description' => t('A serialized array of function names (like node_load) to be called to load an object corresponding to a part of the current path.'),
 'type' => 'varchar',
 'length' => 255,
 'not null' => TRUE,
 'default' => ''),

Here is the problem:
The db field of length 255 can NOT store more than a few (3-4) load arguments (of that kind) at a time. If you specify more of them in hook_menu the string resulting from the serialized array of arguments exceeds the 255 chars limit and is truncated.
As the name of the load function is stored in the array as well and the name can be very long (like 'this_is_my_new_module_load'), you can probably reach that limit with e.g. 2 load arguments already.

Solution is simple:
Extend the field to a length that can store the serialized array without truncation. 768 chars should do (better 1024 ?).

P.S. I'm currently away from my coding environment, but I will roll a patch later today.

Comments

profix898’s picture

Priority: Critical » Normal
Status: Active » Needs review
StatusFileSize
new1.7 KB

Here is a patch to increase the field size to 1024. I also changed the size of to_arg_functions for the same reason.

gpk’s picture

Status: Needs review » Needs work

Hmmm "Drupal 6 supports MySQL 4.1 or higher" (http://drupal.org/requirements).

"Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 1 to 255 before MySQL 4.0.2 and 0 to 255 as of MySQL 4.0.2." (http://dev.mysql.com/doc/refman/4.1/en/char.html)

VARCHAR of 256 or more characters only came in with MySQL 5.0.3.

Susurrus’s picture

What about just changing these fields to TEXT?

profix898’s picture

This is still an issue! Should I roll a patch that updates the column to TEXT? Or are there any other options?

gpk’s picture

Title: load functions field too short in db » load functions and to arg functions fields too short in db (menu_router)
Version: 6.x-dev » 7.x-dev

This would be fixed first in HEAD, for which VARCHAR(1024) should be fine. However the minor change to the minimum version of MySQL (from 5.0 to 5.0.3) also needs to be included in the patch. See http://api.drupal.org/api/constant/DRUPAL_MINIMUM_MYSQL/7. You might also need to include a/some test case(s).

For 6.x, TEXT would be the only general solution AFAICS. Whether such a change to the schema would make it into a future 6.x release I don't know - I don't know all the ins and outs, but am sure a core committer could shed some light on this. No harm in rolling a patch for this as well :)

profix898’s picture

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

If you take a look at other fields designed to take serialized arguments (e.g. 'access_arguments' in the same table or 'options' in table menu_links) their are all using TEXT. So here is a patch that changes 'load_functions' and 'to_arg_functions' fields to TEXT for Drupal HEAD.

profix898’s picture

Patch still applies ... and the issue is still present and really annoying.

Crell’s picture

Priority: Normal » Critical

We just ran into this issue as well using Views under D6. The more Views arguments you have, the longer load_functions() gets. This bug basically kills any respectfully complex Views or Panels that rely on lots of args. I am therefore bumping this to critical, and it will need to be backported to D6.

gdd’s picture

Status: Needs review » Reviewed & tested by the community

Patch applies, does what its supposed to, all tests pass against HEAD. I think this is good to go.

dries’s picture

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

I've committed this against CVS HEAD. Still needs to go into DRUPAL-6 though. Lowering the version.

gdd’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.93 KB

Patch attached for 6.x-dev. Please credit profix898.

pwolanin’s picture

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

marked http://drupal.org/node/295800 as duplicate

pwolanin’s picture

Version: 7.x-dev » 6.x-dev
Status: Needs review » Patch (to be ported)

yes, needs to go into 6.x

pwolanin’s picture

Status: Patch (to be ported) » Needs review

patch still applies cleanly. As a follow-up, probably 'title_arguments' should be converted to text too for consistency.

catch’s picture

Status: Needs review » Reviewed & tested by the community

Patch applies, I tested this on my personal 6.x site and it didn't cause any problems.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 6.x, will go out with the next release, thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

catch’s picture

Version: 6.x-dev » 7.x-dev
Status: Closed (fixed) » Active

The update should be removed from 7.x - if you upgrade to the latest Drupal 6 you'll get it. If you upgrade from 6.3 to 7.3, you'll also get it due to schema version in system table.

webchick’s picture

Correction. In 7.x, 7010 needs to be renamed to 6048 and located with the 6.x updates to match what's in the 6.x branch.

catch’s picture

StatusFileSize
new1.49 KB
webchick’s picture

Status: Active » Fixed

Small update to comment (made it "Moved to system_update_6048().") and committed. Thanks a lot!

Status: Fixed » Closed (fixed)

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