Closed (fixed)
Project:
Media Manager
Version:
5.x-0.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
11 Dec 2007 at 10:48 UTC
Updated:
31 Dec 2007 at 13:51 UTC
I thought I was stupid, when I couldn't configure stuff you were mentioning in your other posts. But here (Firefox 2, Linux) the links actually won't work. (With and without clean URLs)
Comments
Comment #1
rhys commentedI'm not quite sure what you mean by the links don't work.
Where exactly? q=admin/settings/media ???
Comment #2
Ibn al-Hazardous commentedYes, the links in ?q=admin/settings/media give me exactly the same view as ?q=admin/settings/media itself.
Comment #3
rhys commentedThe reason it goes back to the same page, is that the system invalidates those menu items whose function doesn't exist correctly, and I suspect that it's trying to look for the function but is not finding it.
They work on my systems, so I'm not sure how to replicate the error. What version of PHP, etc are you using?
Comment #4
Ibn al-Hazardous commentedPHP 5.2.5-pl0-gentoo
mysql 5.0.44
Apache/2.2.6
I'll look around and see if I find the cause.
Comment #5
Ibn al-Hazardous commentedI'm digging around, and trying to follow this - and where I'm lost is in function media_admin_from in includes/form-admin.inc
I can see that the callback to invoke the forms come inte that function as the variable $func, but whither does it go after that?
Grep tells me that the only function ever refering to media_admin_settings_form is media_media_menu, which returns it by way of module_invoke_all/media_invoke_menu. So, to me it looks like it's left dangling. Could it be that you have a local uncommited file? (Or am I truly too dense? :p )
Cheers!
Comment #6
rhys commentedBasically all the menu functions go through media_invoke_menu.
The admin menu options go through media_invoke_menu('admin')...
The function is located in the includes/module.inc file...
It is supposed to check that the results, including checking whether the function is supposed to exist.
It's probably somewhere in there that there is a problem.
Comment #7
Ibn al-Hazardous commentedLong answer (with debug info):
One piece of version info I forgot last time was:
Drupal 5.5
Anyway, I've been trying to parse this, and this is how I understand what I see:
media_invoke_menu('admin') invokes module_invoke_all('media_menu','admin')
then it checks the returned menu options, so that they are valid.
module_invoke_all('media_menu','admin') invokes hook_media_menu('admin') (right?)
in the case 'admin' part the $items array is filled with options (func, title, descr), where the func part is the only reference to the callbacks (so I gather that this array element must be matched to actually call the func).
In the case 'admin' part there is an additional part arg(3)=='derivatives', still - this doesn't mean that the media_admin_derivatives_add_form (or any other) is called, even if I add "/add" or "/edit" to the URL.
So, the array is returned to module_invoke_all, and then to media_invoke_menu, which checks the validity and returns it to media_admin_form in the file form_admin.inc
But media_admin_form drops the $func - so I guess it must be module_invoke_all that does the actual calling - but checking http://api.drupal.org/api/function/module_invoke_all/5 I can't see that it is invoking stuff from the result array.
So where is $func called?
======
When I run
grep "media_admin_settings" * -r
...it returns:
includes/form-admin.inc:function media_admin_settings_form() {
media.module: 'settings' => array('media_admin_settings_form',
The latter hit is in media_media_menu.
======
So I went one step further and changed media_invoke_menu like this:
+++
function media_invoke_menu($op, $item = null) {
global $debug_m;
$options = module_invoke_all('media_menu', $op, $item);
foreach ($options as $key => $value) {
// make sure that it matches what we're expecting
if (!is_string($key) || !preg_match('/^[\w_\-\/]+$/i', $key) || !is_array($value) || !isset($value[0]) || !function_exists($value[0])) {
$debug_m.="Unset: $key\n";
unset($options[$key]);
} else {
$debug_m.="Keep: $key\n";
}
}
return $options;
}
+++
And I added this at the bottom of media.module (to print the debug data):
+++
function media_footer($main=0)
{
global $debug_m;
return "
";
}
+++
Oh, and in form_admin.inc I also added:
+++
global $debug_m;
$debug_m.=print_r($options,true);
+++
right after:
$options = media_invoke_menu('admin');
Here's the result:
Keep: attach
Keep: embed
Keep: settings
Keep: derivatives
Keep: derivatives/add
Keep: extensions
Keep: types
Keep: programs
Keep: presenters
Array
(
[attach] => Array
(
[0] => media_attach_admin_settings_form
[1] => Attachments
[2] => Attachment settings
)
[embed] => Array
(
[0] => media_embed_settings_form
[1] => Embedding
[2] => For determining what is is embedded and how.
)
[settings] => Array
(
[0] => media_admin_settings_form
[1] => Settings
[2] => Description
)
[derivatives] => Array
(
[0] => media_admin_derivatives_form
[1] => Derivatives
[2] => Description
)
[derivatives/add] => Array
(
[0] => media_admin_derivatives_add_form
[1] => Add Derivative
)
[extensions] => Array
(
[0] => media_admin_extensions_form
[1] => Extensions
[2] => Description
)
[types] => Array
(
[0] => media_admin_types_form
[1] => Types
[2] => Description
)
[programs] => Array
(
[0] => media_admin_programs_form
[1] => Programs
[2] => Description
)
[presenters] => Array
(
[0] => media_admin_presenters_form
[1] => Presenters
[2] => Description
)
)
================
So, it doesn't look like media_invoke_menu is erasing stuff that should be kept. Thus my question; could it be that you have a local file that is missing in CVS?
Comment #8
rhys commentedIf it is keeping all the menu items, that is good.
Where it gets called is in the section in media.module, in hook_menu()... since that is where the menu items are being setup for the admin. Let me have a look at see if there is some potential problem that is creating problems.
Comment #9
Ibn al-Hazardous commentedIt seems the problem is that I have caching turned off.
I replaced "if ($may_cache) {" with "if (1) {" and the menus came up!
Comment #10
Ibn al-Hazardous commentedSlight problem left: The admin menu doesn't play well with the DHTML-menu module. Having a subentry (Add Derivative) makes admin/settings/media inaccessible.
Comment #11
rhys commentedOk, so I looked through again the menu code, and it seems that I made a mistake on how the admin menus are setup. Originally they were in the not $may_cache area, and so functioned correctly. But I placed the menus instead in the may_cache section, encased in provisos and so they didn't load correctly. I'll be changing this soon, so that the admin menus are there regardless, with the proper authority checking.
I'll look into the DHTML menu and why it's not loading them correctly.
Comment #12
rhys commentedSo I looked at the code for the admin menu, and what was the problem is how the menu system caches some of the menu, when the access settings weren't set correctly.
I've since changed that, so hopefully the changes I've made deal with the problem of the links not showing up properly.
Comment #13
Ibn al-Hazardous commentedConfirming that it works nicely now! :)
Comment #14
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.