Multiple listeners order subscribed to the same event?

Discussion forum for Extension Writers regarding Extension Development.
User avatar
martti
Registered User
Posts: 860
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Multiple listeners order subscribed to the same event?

Post by martti »

Is there a way to determine or to set the order in which listeners are called when they are subscribed to the same event? This when more than one extension uses the same event. The question is for both php and template events.
Last edited by martti on Wed Sep 10, 2014 7:05 am, edited 1 time in total.
User avatar
John P
Registered User
Posts: 1237
Joined: Mon Jan 21, 2008 3:55 pm
Location: Netherlands
Name: John
Contact:

Re: Multiple listeners order subscribed to the same event?

Post by John P »

In CLI you can get a list:
php ./bin/phpbbcli.php container:debug --tag="event.listener"
Image
Webhosting, Custom MODs, Technical management, MOD installation and Webdesign
User avatar
MattF
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 5187
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: Multiple listeners order subscribed to the same event?

Post by MattF »

martti wrote:Is there a way to determine or to set the order in which listeners are called when they are subscribed to the same event? This when more than one extension uses the same event. The question is for both php and template events.
No, there is no way to set the order at this time.
Formerly known as VSEMy ExtensionsPlease do not PM me for support.
nicofuma
3.2 Release Manager
3.2 Release Manager
Posts: 546
Joined: Sun Apr 13, 2014 1:47 am
Location: Grenoble - France

Re: Multiple listeners order subscribed to the same event?

Post by nicofuma »

You can set a priority for your php listener but for the template events you can't do anything.
Member of phpBB Development-Team
No Support via PM
User avatar
david63
Registered User
Posts: 18105
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Contact:

Re: Multiple listeners order subscribed to the same event?

Post by david63 »

nicofuma wrote:You can set a priority for your php listener but for the template events you can't do anything.
How is this done and is it set by the extension developer or the user?
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored
nicofuma
3.2 Release Manager
3.2 Release Manager
Posts: 546
Joined: Sun Apr 13, 2014 1:47 am
Location: Grenoble - France

Re: Multiple listeners order subscribed to the same event?

Post by nicofuma »

Member of phpBB Development-Team
No Support via PM
User avatar
david63
Registered User
Posts: 18105
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Contact:

Re: Multiple listeners order subscribed to the same event?

Post by david63 »

But how can one developer know what impact another developer's extensions will have on their, or any other, extensions?

Yes a developer can prioritise their own extensions but the priority in which extensions can run on any particular board will be dependant on the other extensions that have been installed on that board and only the board admin will know that.

If developers can prioritise extensions then there is the possibility that they will give all their extensions a high priority and we will be back to "square one"
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored
nicofuma
3.2 Release Manager
3.2 Release Manager
Posts: 546
Joined: Sun Apr 13, 2014 1:47 am
Location: Grenoble - France

Re: Multiple listeners order subscribed to the same event?

Post by nicofuma »

yes indeed but it's how it works now.
Member of phpBB Development-Team
No Support via PM
User avatar
PayBas
Former Team Member
Posts: 930
Joined: Thu May 25, 2006 12:37 am

Re: Multiple listeners order subscribed to the same event?

Post by PayBas »

david63 wrote:If developers can prioritise extensions then there is the possibility that they will give all their extensions a high priority and we will be back to "square one"
I don't think that's really something to worry about. The extension validation policy will probably have a clause in which it states that setting listener priorities without a valid reason is not allowed.

In any case. Extension authors that set all their listeners to the highest possible priority "just because its fun" should be shot. Twice.
User avatar
martti
Registered User
Posts: 860
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: Multiple listeners order subscribed to the same event?

Post by martti »

When no order is set or in the case of a template event in what order would the listeners be called? Is it the order that the extensions were enabled by the admin?
User avatar
MattF
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 5187
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: Multiple listeners order subscribed to the same event?

Post by MattF »

I believe the order of template events is alphabetical, by vendor name.

Extension developers should not be setting any kind of priorities. As mentioned previously, this is impossible to control in any meaningful way, and it would be abused by some as well. It most likely will not be allowed in extensions we validate unless there is a very good reason for it.

Template event priority is the biggest concern people have raised, and it is under discussion how to address this in phpBB 3.2, because the reality is that a board admin will be the one who should control the order of events, so they can control the way their board looks.

https://area51.phpbb.com/phpBB/viewtopi ... 08&t=45227
This discussion is related. unfortunately it gets derailed into extension dependencies, which is not the point. The point is ordering template events to control the user facing experience ;)
Formerly known as VSEMy ExtensionsPlease do not PM me for support.
nicofuma
3.2 Release Manager
3.2 Release Manager
Posts: 546
Joined: Sun Apr 13, 2014 1:47 am
Location: Grenoble - France

Re: Multiple listeners order subscribed to the same event?

Post by nicofuma »

VSE wrote:I believe the order of template events is alphabetical, by vendor name.
You should assume that it's random.
To be precise it depends on the order in the database which mostly depends on the "first enabled order" (but this order is dependent of the database so...)
Member of phpBB Development-Team
No Support via PM
User avatar
david63
Registered User
Posts: 18105
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Contact:

Re: Multiple listeners order subscribed to the same event?

Post by david63 »

Only time is going to tell whether this is a problem and how big a problem it is and I doubt that there will ever be an ideal solution.

No extension developer can be expected to test the impact that their extension will have on other extensions - it is exactly the same as currently with mods where the only requirement is that a mod works on a vanilla board. However having said that with mods it is easier to "merge" two conflicting mods as you can see the effect on core code.

The advantage that extensions have over mods is that it is very quick and easy to disable it if there is a problem.
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored
rxu
Extensions Development Team
Posts: 3364
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Name: Ruslan
Contact:

Re: Multiple listeners order subscribed to the same event?

Post by rxu »

Developing 2 extensions side by side I already faced the case where setting priority is required. Particularly, those are 'First post on every page' which modifies post_list, and 'Thanks for posts' which uses post_list to output content for every post. I had to set higher priority go the former ext listener to allow latter one using updated post_list.
So, I guess listeners prioritizing isn't going to be that rare case with extensions.
User avatar
david63
Registered User
Posts: 18105
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Contact:

Re: Multiple listeners order subscribed to the same event?

Post by david63 »

rxu wrote:Developing 2 extensions side by side I already faced the case where setting priority is required. Particularly, those are 'First post on every page' which modifies post_list, and 'Thanks for posts' which uses post_list to output content for every post. I had to set higher priority go the former ext listener to allow latter one using updated post_list.
So, I guess listeners prioritizing isn't going to be that rare case with extensions.
That's fine when they are both your own extensions but how would you, or anyone else, handle it if they were written by two, or more, different developers?
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored
Post Reply

Return to “Extension Writers Discussion”