View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0022107||mantisbt||plug-ins||public||2017-01-03 18:58||2017-06-07 06:13|
|Target Version||2.0.1||Fixed in Version||2.0.1|
|Summary||0022107: EVENT_MENU_MAIN does not support relative paths|
According to the documentation for EVENT_MENU_MAIN relative paths seem to be preferred over absolute URLs. However, it seems to be impossible to use relative paths. If I set 'link' to a path returned by the plugin_page function, the menu option will point to http://plugin.php/?page=..., missing the domain part.
I'm not sure whether it does matter, but my Mantis installation has no real domain. It is reachable locally only, under http://btr. Maybe this confuses the code.
|Tags||No tags attached.|
It's not really clear how you're trying to set your link, maybe a code snippet would help. Posting the generated HTML may also be useful, as well as your instance's relevant configuration (config_inc.php).
Please see https://github.com/mantisbt-plugins/source-integration/blob/master/Source/Source.php#L145 for a working example of a plugin link with this event
The code of the Source Integration plugin is for Mantis 1.3. I've no problem with Mantis 1.3, but with 2.0.
The HTML looks like this:
So the problem seems to be that Mantis adds an extra slash to the link, accidently turning it into a protocol relative url. My config file contains only the database and email config.
EDIT: fix markdown
My apologies, I mistakenly linked to the wrong branch, the URL should have been
Notice the use of 'true' as second parameter to plugin_page.php, which will bypass the use of helper_mantis_url(). See  for an explanation of the change.
Let me know if that fixes the problem.
Yes, this fixes the problem, thank you. However, I'm not really convinced that this is the way to go. Maybe I misunderstand the use of the $p_redirect parameter. To me this seems more like a workaround than a proper solution. In my opinion a proper solution would be to check whether the link starts with a slash and not add an extra slash if it does.
You may be right, actually.
What helper_mantis_url() does is prepend the given URL with $g_short_path, so simply checking for a leading '/' would definitely not be the right way to fix this, as it would only work if Mantis were installed at the root. The function would have to determine whether the short path has already been added.
The change seems to be in the 2.0.x branch only. I cannot see it in the 2.1.0 release. Does this mean that it won't be merged to future versions of Mantis?
@TiKu the 2.0.x branch as been merged into master; this is fixed in 2.1 as well:
@dregad Ah, thank you. I've misinterpreted the changelog.
MantisBT: master-2.0.x bbf4cac7
2017-01-04 08:43:37Details Diff
|Allow helper_mantis_url() to be called twice
Starting with Mantis 2.0, the Layout API's layout_sidebar_menu()
function takes care of calling helper_mantis_url() for relative URLs in
Since that function blindly prepends $g_short_path to the given URL,
this causes issues for plugins relying on a plugin_page() call with
default parameters, e.g. to display menu items via EVENT_MENU_MAIN
event, because the short path is prefixed twice resulting in generation
of an invalid URL.
As pointed out by user @TiKu in 0022107:0054922 using plugin_page()'s $p_redirect
parameter = true as it was done for the Source Integration plugin  is
really a workaround.
This commit fixes the issue by only prepending the short path if it is
not yet part of the given URL string.
|mod - core/helper_api.php||Diff File|
|2017-01-03 18:58||TiKu||New Issue|
|2017-01-04 04:21||dregad||Status||new => feedback|
|2017-01-04 04:21||dregad||Note Added: 0054914|
|2017-01-04 05:34||TiKu||Note Added: 0054920|
|2017-01-04 05:34||TiKu||Status||feedback => new|
|2017-01-04 07:35||dregad||Assigned To||=> dregad|
|2017-01-04 07:35||dregad||Status||new => feedback|
|2017-01-04 07:35||dregad||Note Added: 0054921|
|2017-01-04 07:49||TiKu||Note Added: 0054922|
|2017-01-04 07:49||TiKu||Status||feedback => assigned|
|2017-01-04 08:40||dregad||Note Added: 0054923|
|2017-01-04 08:42||dregad||Product Version||2.0.0 => 2.0.0-beta.1|
|2017-01-04 08:42||dregad||Target Version||=> 2.0.1|
|2017-01-06 18:22||dregad||Note Added: 0054968|
|2017-01-09 09:05||dregad||Changeset attached||=> MantisBT master-2.0.x bbf4cac7|
|2017-01-09 09:05||dregad||Status||assigned => resolved|
|2017-01-09 09:05||dregad||Resolution||open => fixed|
|2017-01-09 09:06||dregad||Fixed in Version||=> 2.0.1|
|2017-02-01 04:48||TiKu||Note Added: 0055430|
|2017-02-01 05:24||dregad||Note Added: 0055434|
|2017-02-01 05:29||TiKu||Note Added: 0055435|
|2017-02-01 22:48||vboctor||Status||resolved => closed|
|2017-06-07 06:13||dregad||Note Edited: 0054920||View Revisions|