We have moved to Github. Please open tickets there.

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#3494 closed Enhancement (wontfix)

Find way to remove plugin initialization boilerplate

Reported by: ewinslow Owned by:
Priority: normal Milestone: Needs Review
Component: Core Version: 1.7
Severity: minor Keywords:
Cc: brett@… Difficulty:

Description

Virtually every plugin does this:

elgg_register_event_handler('init', 'system', 'plugin_init');

function plugin_init() {
  //stuff
}

I know it's not much, but why not just kill the boilerplate and go with an init.php that just contains //stuff?

Main problem I can forsee with that approach would be the confusion b/w start.php and init.php. However, the benefit is that it's fully backwards compatible. The developers plugin is the only plugin I know that does anything different and it actively discourages plugins from doing the same.

Change History (3)

comment:1 Changed 2 years ago by cash

  • Resolution set to wontfix
  • Status changed from new to closed

Costs outweight the benefit by a lot: new developer confusion, loading lots of extra files, special exceptions for events (init,system versus all other events), making plugin loading more complicated.

comment:2 Changed 2 years ago by ewinslow

Bah, I know you're right. I just hate it. Why do we use this event anyways, rather than executing the code right away in start.php? We can't even do this in a 2.0 type release?

comment:3 Changed 2 years ago by cash

There is nothing stopping a plugin developer from putting initialization code right in start.php rather than using the event system.

We'll never know why to most things with Elgg.

I'm partial to the init, system event because it has the core libraries and plugins booting at the same time. If I wanted to register my init function with a high (small number) priority, I could run before a core library's init function (or even unregister it). It feels more orderly to me and I'm willing to type in the extra 40 characters to get that.

Note: See TracTickets for help on using tickets.