Can an action callback prevent the parent from continuing execution?

Short answer: no.

Long answer: also no. Actions don’t work that way.

Edit:

To elaborate and make your question totally generic:

function foo() {
  bar();
  return 1;
}

function bar() {
  // stuff
}

There is nothing you can put in stuff that will prevent a call to foo() from returning 1, other than halting script execution entirely with die or exit.

Note: Throwing exceptions won’t help either, because this has the same effect as halting script execution unless some previous caller catches the exeception.

Now, if this function is in a class somewhere, then you can define a subclass of it and replace this function with one of your own, then potentially use that, thus modifying the way this function works. That’s about the best you can do, since PHP doesn’t have any sort of aspect-oriented-programming mechanisms in it that would allow you to change function behavior at runtime.

Leave a Comment