Menu hook

vflirt - November 3, 2008 - 09:11
Project:Sphinx (Sphinx search integration)
Version:6.x-1.x-dev
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:postponed (maintainer needs more info)
Description

Well it is not a bug but is kinds undeed source you have in the menu hook. The menu in drupal 6.* is caches and is rebuild only when you go to admin/build/modules or in the admin you select to rebuild menu with the devel module. All the rest cases the menu is cached and actually if you start fresh install of the module and then add some indexes then "search/main_index" and "search/main_index/%" paths will not be added to the menu before you rebuild it. All this source from the menu hook :

$res = db_query('SELECT iid, display_name, path FROM {sphinx_indexes} WHERE active = 1');
while ($indexes = db_fetch_object($res)) {
$items['search/'. $indexes->path] = array(
'title' => t('Search !index', array('!index' => $indexes->display_name)),
'description' => t('Search !index', array('!index' => $indexes->display_name)),
'page callback' => '_sphinx_search_page',
'page arguments' => array(1, ''),
'access callback' => user_access('use index '. $indexes->display_name .'('. $indexes->iid .')'),
'type' => ($indexes->path == variable_get('sphinx_default_index', '')) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
);
$items['search/'. $indexes->path. '/%'] = array(
'title' => t('Search !index', array('!index' => $indexes->display_name)),
'description' => t('Search !index', array('!index' => $indexes->display_name)),
'page callback' => '_sphinx_search_page',
'page arguments' => array(1, 2),
'access callback' => user_access('use index '. $indexes->display_name .'('. $indexes->iid .')'),
'type' => ($indexes->path == variable_get('sphinx_default_index', '')) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
);
}

is kinda unneded cause it will always call the _sphinx_search_page with the appropriate arguments.
Well that is just a suggestion for a cleaner code :)

#1

johsw - November 14, 2008 - 23:00
Status:active» postponed

There is no official d6 release yet.

#2

johsw - September 23, 2009 - 21:56
Version:5.x-1.x-dev» 6.x-1.x-dev
Status:postponed» active

I do it this way to make it possible to have per index permissions (that could be done with a custom access function), but it also allows a MENU_DEFAULT_LOCAL_TASK

Please send me a patch, if you've got a cleaner way to do it.

#3

johsw - September 23, 2009 - 21:56
Status:active» postponed (maintainer needs more info)
 
 

Drupal is a registered trademark of Dries Buytaert.