Using the standard profile shortcut module installs fine.
Using a custom profile, which doesn't include menu module, throws the following error upon installation:

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: http://example.com/install.php?profile=example_profile&locale=en&id=1&op=do StatusText: Service unavailable (with message) ResponseText: PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY fit DESC LIMIT 0, 1' at line 1: SELECT * FROM {menu_router} WHERE path IN () ORDER BY fit DESC LIMIT 0, 1; Array ( ) in menu_get_item() (line 443 of /path/to/drupal/includes/menu.inc).

I tried adding menu module as a dependency of shortcut module and that resolved the error. Then I tried a drupal_flush_all_caches() in shortcut_install() and that also resolved the error. menu_cache_clear() and menu_cache_clear_all() did not resolve the error.

So without actually knowing what's going on, here's a minimal patch to stop the bleeding. Leaving at active, though, because while this patch might be useful in the end, it would be best to find out what is actually going on.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

David_Rothstein’s picture

Title: Shortcut module cannot be installed due to caching issues » Shortcut module cannot be installed via an install profile if the menu module wasn't installed first
Status: Active » Needs review
FileSize
695 bytes

The issue seems to be that menu_enable() calls menu_rebuild(), and before that there isn't anything in the {menu_router} table at all, so it's empty at this point if the menu module wasn't installed first.

For Drupal 7, at least, I think something like the attached is the right solution?

Since this is a problem other modules could face too, we could also add an initial menu_rebuild() to the installer before modules start installing, but it doesn't totally fix this situation anyway, since it won't have most modules' links in it yet (if they haven't been installed yet themselves) which means not all of the shortcuts will be saved correctly.

tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

Ahh thanks for tracking that one down. Looks RTBC to me.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Hm. I'd really rather not fix it this way if we can avoid it. It'd be nice to do something in the installer to ensure that the menu's there for all modules.

Could we try the initial menu_rebuild() approach instead, and see if it solves this particular problem?

David_Rothstein’s picture

Status: Needs work » Needs review

Already tried. See #1 (and the code comment in the patch).

Not sure if the code comment needs more detail, but basically the issue is that since the shortcut module is adding links that point to paths defined by the node module, it won't work if the menu_rebuild() happens before the node module was ever installed. (Though strangely, it works better than you'd think; one of the links gets saved correctly and the other doesn't, which I think is related to the fact that one of the link titles is the same as the router item title in node_menu() and the other isn't.)

So basically, the only way we can guarantee that the menu rebuild is up-to-date is to do it right when we need it.

It may make sense to add another menu_rebuild() early in the installer (for other modules' sake), but since it won't help here I don't think it's worth doing here; we don't really know if there's any actual thing it helps with. Also, adding two menu_rebuilds (to slow down the installer) as part of the same issue is just too sad, I think :)

David_Rothstein’s picture

Came across another case of this in contrib: #1087346: Drupal can't be installed when Media Gallery is enabled via an install profile.

Same problem there, though; if we added a menu_rebuild() to the beginning of the installer in Drupal core, it would prevent the fatal error, but still wouldn't let the Media Gallery module's install hook work the way it's supposed to. So to properly fix the bug Media Gallery needs to add its own menu_rebuild() anyway (short of making bigger changes to the menu system to enable what these modules are trying to do without a full rebuild).

tstoeckler’s picture

Tentatively marking RTBC.
I think the reasoning in #1, #4, and #5 is sound, so I don't know what else needs to be done?

tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

Oops.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Ok... This still feels like a sub-optimal fix, but I understand the reasoning. And I admit I can't come up with anything better...

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

catch’s picture

I just found #1177830: shortcut_install() should be in standard_install() - that looks like the proper/Drupal 8 fix to me but would not have been possible for Drupal 7.

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