Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-01-24 07:41:48

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Order of plugin execution

Currently (v4.0.3), plugins are stacked in the global $plugins array based on whatever order you happened to add them into your Textpattern install and then iterated through one by one, in order, and loaded into memory via load_plugins().

The trouble comes when you have a plugin that works symbiotically with another plugin by acting as an optional middleman to data-processing (both using the same callback method), then passing off control. In this case, neither plugin includes or requires the other, but one plugin must access the callback method first in order for the dependent plugin to work correctly in certain circumstances.

For instance, ajw_clean_feed passes off clean urls for sitewide comments to ajw_comments_feed by setting the appropriate GET value and exiting plugin execution, assuming the latter will then take control. Its functionality depends on the assumption that ajw_clean_feed precedes ajw_comments_feed in accessing the “pretext” callback.

Anyone have any clever ideas as to how we can add an override to the load_plugins() function so that I can avoid bug reports for 1/2 of the people who just happened to install the plugins in the incorrect order?

Last edited by Andrew (2006-01-24 07:46:14)

Offline

#2 2006-01-24 12:27:37

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: Order of plugin execution

in this case, neither plugin includes

Have you tried it? Use @include_plugin and you will make sure that if the other plugin is present it wil always be loaded first. If you then register your callback after the include-line, I think it should solve your problem.

Offline

#3 2006-01-24 16:08:59

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: Order of plugin execution

I’ll give it a shot…

Offline

#4 2006-01-24 17:47:44

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: Order of plugin execution

Brilliant. Purely brilliant.

I had tried that earlier without success, assuming include_plugin() was for external libraries and might not work for callback-triggered plugins, but I didn’t add the include line before registering the callback. Now we’re golden.

Thanks!

Last edited by Andrew (2006-01-24 17:48:02)

Offline

Board footer

Powered by FluxBB