Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

onAfterUnpublish does not get called when I unpublish a page


Go to End


6 Posts   1118 Views

Avatar
Nivery

Community Member, 6 Posts

17 July 2012 at 7:23am

My onAfterPublish function gets called when I publish a page, but my onAfterUnpublish function does not get called when I unpublish. Is there anything extra (outside of just defining the function as I did with onAfterPublish) that I need to do to make sure onAfterUnpublish gets called when I unpublish?

Avatar
Willr

Forum Moderator, 5523 Posts

17 July 2012 at 6:23pm

Both should behave in the same fashion. The onAfterPublish event is triggered in the doUnpublish function inside SiteTree.php. I suggest you debug through SiteTree.php and see if that code is actually being called.

Avatar
Nivery

Community Member, 6 Posts

18 July 2012 at 3:21am

Thanks for responding.

Putting user_error("breakpoint", E_USER_ERROR) right below $this->extend('onAfterUnpublish') in the doUnpublish() function of SiteTree.php does produce an error, so I know it's gets to the point in doUnpublish where onAfterUnpublish gets triggered.

For clarity's sake, putting the same statement at the top of my onAfterUnpublish function produces no error because onAfterUnpublish isn't getting called by doUnpublish.

Neither onBeforeUnpublish or onAfterUnpublish work for me FWIW.

Avatar
Nivery

Community Member, 6 Posts

19 July 2012 at 12:13pm

Any other suggestions? I am using 2.4 in case that wasn't clear.

Avatar
Nivery

Community Member, 6 Posts

1 August 2012 at 2:43am

I apologize if this bump is inappropriate, but as I am still struggling with this problem, I thought I'd solicit help another time. :)

Avatar
Willr

Forum Moderator, 5523 Posts

1 August 2012 at 8:47am

So it's callin the code, is your extension added to the sitettree base class?