View Issue Details

IDProjectCategoryView StatusLast Update
0022210mantisbtplug-inspublic2017-05-12 18:03
Reportermboutell Assigned Todregad  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionunable to reproduce 
Summary0022210: Plugin "priority" is not working
Description

I added a plugin on my instance which use the event EVENT_VIEW_BUG_DETAILS to add some fields.
I already have a plugin which do the same. I want to choose the order of display between these two plugins.
I thought the value "priority" in "manage plugins" will help me but even if I change the value it has no effect.
I'm in mantisbt 1.2.17.

Thank you.

TagsNo tags attached.
Attached Files

Activities

dregad

dregad

2017-01-16 07:53

developer   ~0055148

I never actually had the need to use plugin priority, but I'll try to have a look. It would be nice if you could specify/provide the plugins you are using, to facilitate problem reproduction.

mboutell

mboutell

2017-01-16 08:00

reporter   ~0055150

Last edited: 2017-01-16 10:23

The plugins are the ones I developped.
I'm not sure my need was clear :

My plugin A adds a field in the issue thanks to "EVENT_VIEW_BUG_DETAILS"
My plugin B also adds a field.
I want the following order :

  • field created by plugin B
  • field created by plugin A

And it's not the case. So, if priority can't help me, when this value is used ? Is there a way to order my plugin fields ???

EDIT (dregad): changed 'had' to 'add' per mboutell's request

dregad

dregad

2017-01-16 10:22

developer   ~0055156

I think it was clear from the start, but thanks for updating anyway.

The reason for my request, is that if indeed the priority should impact the order in which fields are displayed, then it would be helpful and better to have existing, real-life code to test that the feature works as expected, rather than having waste time to write dummy test plugins for that.

dregad

dregad

2017-01-16 11:19

developer   ~0055157

As far as I know, priorities determine the order in which plugins are registered, and therefore (in theory) the order in which the callback are executed. In addition, for events of type "first", callbacks processing will stop after the first non-null value is returned.

cproensa

cproensa

2017-01-16 17:39

developer   ~0055169

Last edited: 2017-01-16 17:39

I have tested with my installed plugins, wich also uses EVENT_VIEW_BUG_DETAILS
Priority does change the order of the output from the plugins.
Note that a higer priority, eg: 5 will cause this plugin to be executed before another one with lower priority, eg: 1

As far as i know, this hasn't been changed from mantis 1.2.x to 1.3.
I think you have misunderstood the priority precedence.

mboutell

mboutell

2017-01-17 02:25

reporter   ~0055172

I'm sorry but I used 5 for my plugin B and 1 for my plugin A and my plugin B is still called before (At least the fields from plugin A are displayed before the ones of plugin B)
Before creating this issue I've tested many values ;)

cproensa

cproensa

2017-01-17 02:45

developer   ~0055173

Im sorry but I used 5 for my plugin B and 1 for my plugin A and my plugin B is still called before

Thats exactly the behaviour i described: plugin B with priority=5 executes before plugin A with priority=1

(At least the fields from plugin A are displayed before the ones of plugin B)

That's contradictory, you said "plugin B was called before A"

mboutell

mboutell

2017-01-17 02:53

reporter   ~0055174

Exactly my answer was contradictory :
Currently :
Plugin A : priority 1
Plugin B : priority 5

the plugin A is called before my plugin B

(sorry for my last answer)

mboutell

mboutell

2017-01-30 09:05

reporter   ~0055395

Any other suggestion ? Still can't use priority...

mboutell

mboutell

2017-02-21 03:15

reporter   ~0055728

Is there something to activate ? I can't find where the priority is used in the code.
Any support? It's very important. Thank you

mboutell

mboutell

2017-05-03 06:07

reporter   ~0056768

I still can't choose the priority of my plugins.
Any help ?

dregad

dregad

2017-05-03 11:42

developer   ~0056770

Hello,

I took the time today to create a couple dummy plugins to test this. They simply display the plugin's name and assigned priority when EVENT_VIEW_BUG_DETAILS is sent.

Here is the source code (the only difference between the 2 plugins being their name)

<?php
class p1Plugin extends MantisPlugin {
    function register() {
        $this->name = 'Test 1';
        $this->version = '1.0';
    }

    function hooks() {
        return array( 'EVENT_VIEW_BUG_DETAILS'  => 'view' );
    }

    function view( $p_event, $p_bug_id ) {
        printf( "<div>%s (priority %d)</div>", $this->name, plugin_priority(plugin_get_current()) );
    }
}

After installing the 2 plugins, I tested as follows, by setting:

  1. plugin 1 with priority 1 and plugin 2 with priority 3
  2. changed plugin 1 priority to 5, left plugin 2 with priority 3

As shown in the attached screenshot, the system works as expected, i.e. the plugin with the higher priority displays first

plugins_priority.png (5,467 bytes)   
plugins_priority.png (5,467 bytes)