[2.0] New event hooks for plugin installation/update

Discussion corner for Developers of Serendipity.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

[2.0] New event hooks for plugin installation/update

Post by garvinhicking »

Hi!

Timbalu proposed a while ago to add new methods for when a plugin is installed/updated. Currently, plugins like serendipity_event_staticpage execute their own method on each call to see if they are running the latest version.

I have now added new event hooks to the core:

* backend_templates_install
Executed when a new template is selected.
$eventData: Name of the template
$addData: Array of template information (fetchTemplateInfo)

* backend_plugins_install
Executed after a new plugin was (possibly downloaded) installed. This is on top of $plugin->install(), the hook is executed after this. This hook is actually NOT meant for the plugin itself to hook into, but for other plugins to possibly perform actions when a compatible plugin is installed - like, serendiity_event_staticpage could create additional SQL tables, if serendipity_event_freetag is installed. Then the plugin would not need to check everytime if the serendipity_event_freetag plugin is loaded and the tables already exist.
$eventData: Name of the plugin
$addData: Array of $serendipity plus GET data

* backend_plugins_update
Executed after an existing plugin was updated. Plugins can check for updates to their own files by hooking into this, but also for other plugins that may have been updated.
$eventData: Name of the plugin
$addData: Array of $serendipity plus GET data


I am not really sure if this is the best way to solve plugin updates. If the upgrade process somehow fails, or timeouts, maybe this event hook might never get executed - the current way plugins check every time again and again if they are the most recent version is much safer - however, also much more impactful to performance. So let's see how this goes. :-)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: [2.0] New event hooks for plugin installation/update

Post by Timbalu »

Sounds exiting! +1
Thank you!

Could we at least downport the last hook (backend_plugins_update) to work with it right now? :wink:
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: [2.0] New event hooks for plugin installation/update

Post by garvinhicking »

Hi!

I did. Would you like to test if it works? ;)

(Plugins need to have a fallback for serendipity <= 1.7.1 at least for some time!)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: [2.0] New event hooks for plugin installation/update

Post by Timbalu »

I definitely will!

I'll try that with ckeditor, but will not do any fallback, since I will bump the required version to 1.7.1 :)
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: [2.0] New event hooks for plugin installation/update

Post by garvinhicking »

I'll try that with ckeditor, but will not do any fallback, since I will bump the required version to 1.7.1 :)
That would be a problem, because then you can test this - if you raise to 1.7.1 before 1.7.1 is released, you'd completely disable the plugin for anyone else.

Also, just because of this update method, no plugin should require 1.7.1, think about the users...

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: [2.0] New event hooks for plugin installation/update

Post by Timbalu »

Sure, this is true in general.
But in this special case it does not really matter, since ckeditor already is >= 1.7 only and I will not update the ckeditor version until 1.7.1 is out as well. :)
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: [2.0] New event hooks for plugin installation/update

Post by garvinhicking »

Hi!

But 1.7.1 is not a mandatory security-releated upgrade. So some people will still run 1.7. Why exclude them from CKEditor, if their version would perfectly run it?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: [2.0] New event hooks for plugin installation/update

Post by Timbalu »

Now I see what you mean.... Its about new installations. Right, I don't want to disable that.
I was thinking in terms of updaters only.... ;-) (I'll see what I can do about it.)

But still it would be like this. Everybody with 1.7 wanting to use the ckeditor plugin could still do this until 1.7.1 and a new ckeditor Plugin is out. Updaters would profit, the other ones wouldn't notice until they want to try out the updated Plugin as new. They would see the note that 1.7.1 is required to install this plugin.

Would Spartacus or our plugin manager disable already running versions on 1.7 if the required version is bumped up?

If not, it wouldn't be that important, to update to a new Plugin (ckeditor) version...
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: [2.0] New event hooks for plugin installation/update

Post by garvinhicking »

I was thinking in terms of updaters only.... ;-) (I'll see what I can do about it.)
:)
But still it would be like this. Everybody with 1.7 wanting to use the ckeditor plugin could still do this until 1.7.1 and a new ckeditor Plugin is out. Updaters would profit, the other ones wouldn't notice until they want to try out the updated Plugin as new. They would see the note that 1.7.1 is required to install this plugin.
Yes. But nobody with < 1.7.1 could then install CKEditor anymore. That's not good, it's not necessary to punish those users.
Would Spartacus or our plugin manager disable already running versions on 1.7 if the required version is bumped up?
They cannot upgrade the plugin then.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: [2.0] New event hooks for plugin installation/update

Post by Timbalu »

garvinhicking wrote:Yes. But nobody with < 1.7.1 could then install CKEditor anymore. That's not good, it's not necessary to punish those users.
I never punish users ... its not my nature ;-)
though it would be nice to have a required version to install and a required version to update routine in spartacus... then this update hook would really be quite powerful!
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: [2.0] New event hooks for plugin installation/update

Post by garvinhicking »

Timbalu wrote:
garvinhicking wrote:Yes. But nobody with < 1.7.1 could then install CKEditor anymore. That's not good, it's not necessary to punish those users.
I never punish users ... its not my nature ;-)
though it would be nice to have a required version to install and a required version to update routine in spartacus... then this update hook would really be quite powerful!
I don't see how this would work? Spartacus only always has the most recent version available.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: [2.0] New event hooks for plugin installation/update

Post by yellowled »

Maybe I don't understand the purpose of this or it might be going too far, but could this
garvinhicking wrote:* backend_templates_install
Executed when a new template is selected.
be used or extended to trigger the installation of plugins as well?

We have some templates which sort of require certain plugins to be installed, e.g. the magazine templates. I think it would be pretty awesome to have those templates trigger the installation of their required plugins automagically, unless this has security implications or is too much of a hassle to code.

YL
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: [2.0] New event hooks for plugin installation/update

Post by garvinhicking »

Hi!
be used or extended to trigger the installation of plugins as well?
Yes. This would be a bit trickier though because spartacus etc. is not really meant to download and install multiple plugins at once. It could be done, but might possibly be sluggish.

But that's a question for the implementation; the foundation for this is available now, yes.

(Of course, previously a templates config.inc.php could also download, install/enable plugins for a long time...)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: [2.0] New event hooks for plugin installation/update

Post by yellowled »

garvinhicking wrote:(Of course, previously a templates config.inc.php could also download, install/enable plugins for a long time...)
Erm, okay … should I be aware of how that works or is this something which we had for a long time but never used? :D

YL
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: [2.0] New event hooks for plugin installation/update

Post by garvinhicking »

Hi!
Erm, okay … should I be aware of how that works or is this something which we had for a long time but never used? :D
You specifically shouldn't be, as it would involve a larger amount of PHP coding. Just saying the foundation/API would also be there to do it. ;)
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply