Topic on Project:Support desk

What's the difference between PageContentSave and EditPage::attemptSave?

4
Flashdash1 (talkcontribs)

These two hooks (Manual:Hooks/PageContentSave and Manual:Hooks/EditPage::attemptSave) seem to both run when an attempt is made to save a page. They provide different parameters to the event handlers, but they seem to trigger at the same time? What's the difference between the two and under what circumstances would one be more appropriate over the other? Thanks.

Ciencia Al Poder (talkcontribs)

EditPage::attemptSave is called at the beginning of internalAttemptSave, after a lot of processing including permissions checks, spam checks, null edits... it calls WikiPage:doEditContent which calls the PageContentSave hook.

Flashdash1 (talkcontribs)

So PageContentSave is for when the page is about to be saved and attemptSave is merely an attempt to save the page and it still has to pass through all those checks, right? If I was making an extension to check the contents of an edit for inappropriate content or spam, it seems it would be better to use attemptSave and abort there if it fails? Thanks.

Ciencia Al Poder (talkcontribs)

Yes, although for your use case it's better to use Manual:Hooks/EditFilter instead, which provides useful variables to give error messages.