View Issue Details

IDProjectCategoryView StatusLast Update
0023694mantisbtplug-inspublic2019-07-06 08:13
ReporterRuzhelovich Vladimir Assigned Todregad  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platform2.8.0OSUbuntuOS Version16.04.3 LTS
Product Version2.0.0 
Target Version2.21.0Fixed in Version2.21.0 
Summary0023694: View Issue page menu links from EVENT MENU_ISSUE event are wrapped with "[", "]" characters
Description

Wrong show the menu of plugins for EVENT MENU_ISSUE event. There are "[","]" characters in this menu.

Steps To Reproduce
//Add menu
       public function add_creat_relationship_link($p_event,$array_bug_list) {
               ob_start();
               print_link_button( $this->t_url, plugin_lang_get( 'creat_relationship' ),"btn btn-primary btn-white btn-round btn-sm$
               $link = ob_get_contents();
               ob_end_clean();
               return array($link);
    }
TagsNo tags attached.
Attached Files
1.png (8,108 bytes)   
1.png (8,108 bytes)   

Activities

Ruzhelovich Vladimir

Ruzhelovich Vladimir

2017-12-04 05:56

reporter   ~0058305

Last edited: 2019-04-12 04:55

Perhaps the problem is in this part ("bug_view_inc.php"):

foreach ( $t_links as $t_plugin => $t_hooks ) {
        foreach( $t_hooks as $t_hook ) {
                if( is_array( $t_hook ) ) {
                        foreach( $t_hook as $t_label => $t_href ) {
                                if( is_numeric( $t_label ) ) {
                                        print_bracket_link_prepared( $t_href );
                                } else {
                                        print_small_button( $t_href, $t_label );
                                }
                        }
                } elseif( !empty( $t_hook ) ) {
                        print_bracket_link_prepared( $t_hook );
                }
        }
}
Ruzhelovich Vladimir

Ruzhelovich Vladimir

2017-12-05 01:18

reporter   ~0058314

For english:

1-2.png (13,668 bytes)   
1-2.png (13,668 bytes)   
dregad

dregad

2019-04-12 06:18

developer   ~0061908

A PR was submitted to fix this issue - https://github.com/mantisbt/mantisbt/pull/1502

This behavior is a leftover from Mantis 1.x where links were shown as [ xxx ], this case was omitted during the ModernUI migration.

Note: the problem only occurs when the plugin's event hook returns cooked links, so IMO the proper way to fix this would be to deprecate print_bracket_link_prepared() function, update event documentation to reflect that it should return an array like [ 'label' => 'link' ] and let plugin authors adapt their code.

dregad

dregad

2019-04-12 11:17

developer   ~0061910

Last edited: 2019-04-12 11:18

Alternate PR https://github.com/mantisbt/mantisbt/pull/1503 addresses the issue by obsoleting print_bracket_link_prepared() function.

As mentioned earlier, plugins should be updated to return an associative array with the link's label as key and the link target as value, e.g.

array( plugin_lang_get( 'mypage_label' ) => plugin_page( 'mypage' );

Related Changesets

MantisBT: master 4714c1ac

2019-04-12 12:59

dregad


Details Diff
Obsolete print_bracket_link_prepared()

This function was used in MantisBT 1.x to display links surrounded by
square brackets for menus. With MantisBT Modern UI, it has been replaced
with CSS styling, to display the links as buttons.

One use case was not properly migrated, when displaying links on View
Issues Page (processing the EVENT_MENU_ISSUE hook).

The problem cannot be fixed properly within MantisBT code, it requires
an update of the Plugin's hook (returning an array of `label => link`
pairs instead of cooked links).

Consequently, the function has been marked as obsolete so that a warning
is displayed, to inform plugin developers that they should update their
code.

Fixes 0023694
Affected Issues
0023694
mod - core/print_api.php Diff File
mod - docbook/Developers_Guide/en-US/Events_Reference_Output.xml Diff File