View Issue Details

IDProjectCategoryView StatusLast Update
0032557mantisbtbugtrackerpublic2025-02-21 18:30
Reporteradachi Assigned Todregad  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version2.23.0 
Target Version2.26.4Fixed in Version2.26.4 
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 
has duplicate 0034677 closeddregad User documentation URL is wrong 
related to 0032703 closeddregad Local documentation is not accessible (403) 
related to 0035322 closedcommunity Incorrect absolute URL in the tab menu 

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.

dregad

dregad

2024-09-20 13:18

developer   ~0069249

PR https://github.com/mantisbt/mantisbt/pull/2029

Related Changesets

MantisBT: master-2.26 952cbc28

2024-09-20 12:55

dregad


Details Diff
Fix broken absolute URL on proj_doc_page.php

Introduce 'absolute' flag in print_menu() items, allowing caller to
decide whether helper_mantis_url() needs to be called on the given url
or not.

Fixes 0032557
Affected Issues
0032557
mod - core/html_api.php Diff File