View Issue Details

IDProjectCategoryView StatusLast Update
0032557mantisbtdocumentationpublic2023-06-06 11:24
Reporteradachi Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status acknowledgedResolutionopen 
Product Version2.25.7 
Summary0032557: Can not set full URL to $g_manual_url in config_inc.php
Description

For example, my site URL is "https://www.sample.com/".
And set "https://www.mantisbt.org/" to $g_manual_url.
Then output is "https://www.sample.com/https://www.mantisbt.org/".

TagsNo tags attached.

Relationships

related to 0016995 closeddregad Absolute g_manual_url becomes relative on proj_doc_page.php 
related to 0032703 closeddregad Local documentation is not accessible (403) 

Activities

dregad

dregad

2023-05-18 05:37

developer   ~0067758

There was a long discussion about this issue, see 0016995 and related GitHub pull request https://github.com/mantisbt/mantisbt/pull/144

The fix I committed back then worked, until a refactoring of the menu building functions broke it again as it channelled the URL again to helper_mantis_url() function.

Considering there was a pretty strong stance at the time against allowing helper_mantis_url() to handle absolute URLs, I'm not really sure how else this could be handled now.
@atrol @vboctor, Thoughts ?

atrol

atrol

2023-06-04 07:59

developer   ~0067818

Last edited: 2023-06-04 08:00

@dregad
I would keep it simple

  • use the URL as it is
  • set default in config_defaults_inc.php to $g_manual_url = $g_path . 'doc/en-US/Admin_Guide/html-desktop/';
  • no special handling in case it does not exist (developers can add add the docs to ther dev box, or add $g_manual_url = 'https://www.mantisbt.org/docs/master/en-US/Admin_Guide/html-desktop/'; to their config_inc.php if they want
  • admins can set the URL to whatever they want
dregad

dregad

2023-06-05 12:31

developer   ~0067826

use the URL as it is

Well that is the problem exactly ! This cannot currently be done, because the code relies on the standard print_menu() function, which always channels the menu item's URL through helper_mantis_url().

So the simplest and most logical fix, would be to let helper_mantis_url() return absolute URLs as-is.

An alternative could be to introduce a flag in the array of menu items passed on to print_menu(), indicating whether the given URL is absolute, and only pass it on to helper_mantis_url() if not. A bit of a hack I guess, but it would be quite easy to implement.

atrol

atrol

2023-06-05 17:09

developer   ~0067827

@dregad concerning

An alternative could be to introduce a flag ...

Why do you need the flag whether the given URL is absolute?
You could check in print_menu() if it's an absolute URL.

dregad

dregad

2023-06-06 02:59

developer   ~0067828

Why do you need the flag whether the given URL is absolute?
You could check in print_menu() if it's an absolute URL.

The absolute URL scenario is a corner case, currently used only for the Admin Guide link (and maybe some plugins); using the flag avoids executing a parse_url() call for every single menu item displayed to detect the URL type (absolute or relative), when the caller actually already knows what it is sending to print_menu().

So my idea was to optimize performance. Maybe using preg_match() with an appropriate regex would be slightly faster than parse_url(), and I guess you could even argue that the gain is negligible anyway, so maybe we should favor user convenience over execution speed here.