SMF icon indicating copy to clipboard operation
SMF copied to clipboard

integrate_default_action

Open emanuele45 opened this issue 14 years ago • 8 comments

@norv

In order to not lose Norv's comment on the integrate_default_action I open this issue. If it is not necessary feel free to close it. ;)

A bit of reference: https://github.com/SimpleMachines/SMF2.1/pull/212#commitcomment-2043749 (Norv's comment) https://github.com/SimpleMachines/SMF2.1/issues/52 (original discussion about the hook)

I'm not sure if the comment was about the general idea of the hook or about my last commit in particular.

The reasoning behind my last commit is: there are already few other hooks that expect a return, the previous way was a bit fragile because we were expecting the mod to set $call to a string. The way I changed it now we know that what we are examining in the loop is an array (returned by call_integration_hook), then the first valid function is used to generate the homepage.

TBH, no I didn't test it.

emanuele45 avatar Oct 25 '12 15:10 emanuele45

Thank you for opening the issue. Lets take a step back here, and look at what is going on.

Problem:

  • hooks in SMF 2.0 were designed to allow multiple actions to be executed at each point in the code.
  • a need has appeared, to have a single, unique action executed, at a particular point.
  • [constraint] SMF should allow registration of more actions, and fall back to the last registered.

Suggested solution:

  • hooks system should allow 'unique actions' (hooks) to be defined
  • for 'unique' actions, call_integration_hook() must execute only the last function registered by some mod.

norv avatar Oct 25 '12 17:10 norv

@norv that sounds confusing and complicated. Might as well hook the fallback action, too!

live627 avatar Nov 19 '12 05:11 live627

The way I'd fix this is a much deeper overhaul of hooks in totality. I'd be giving them the ability to define a priority, perhaps on a scale of 1 to 100, 1 first, 100 last, defaulting at 50 (which is basically order of install)

Then once we know what order a hook's listeners are going to be run at, we can fix this issue cleanly; call each in turn, first one hit that's valid is the one we run with. Then it strictly becomes a mod issue when two mods clash and one mod can take a higher priority and determine if it should be having the front page or not, and return either the function name (or whatever) or return false if it doesn't do anything.

The fallback action if no action is matched is not a bad idea but ultimately should require the same thing to be done to make it work properly, and I'm concerned that rethinking the hook system to enable that is now out of practical scope for 2.1.

Arantor avatar Sep 28 '13 16:09 Arantor

I kinda like Arantor's idea, and also agree this isn't something for 2.1.

Xarcell avatar Jan 15 '14 15:01 Xarcell

I've added the fallback being hookable, but beyond the priority, I'm not sure anything can or will be done about it in 2.1... really, well behaved hooks should be returning fall in those situations anyway if they know they're not going to be called. But with some of the other changes added recently adding hook priority is a hurdle to deal with.

Arantor avatar Jan 18 '14 17:01 Arantor

If this is no longer an issue for 2.1, can we move it to a 3.0 milestone? The milestones really need a cleanup.

Ant59 avatar Apr 29 '14 11:04 Ant59

If it's no longer issue for 2.1 it needs to be closed :)

-----Original Message----- From: "Ant59" [email protected] Sent: ‎29.‎4.‎2014 14:00 To: "SimpleMachines/SMF2.1" [email protected] Subject: Re: [SMF2.1] integrate_default_action (#224)

If this is no longer an issue for 2.1, can we move it to a 3.0 milestone? The milestones really need a cleanup. — Reply to this email directly or view it on GitHub.

XinYenFon avatar Apr 29 '14 11:04 XinYenFon

Agreed. That makes better sense with this being a 2.1 repo :+1:

Ant59 avatar Apr 29 '14 11:04 Ant59