Topic on Project:Support desk

How to create a custom warning message?

8
Pulsargranular (talkcontribs)

I spend now hours to find a way to create a simple warning message after editing and saving a page. Something similar like when you save a page and it tells me «Your edit has been saved» in a green box. It should just be in a different colour (e.g orange, not green). Where can I find documentation about it?

Thank you very much for your help.

Best, Swen

Ciencia Al Poder (talkcontribs)
Pulsargranular (talkcontribs)

Thanks, but this is the answer to something else.

I am in a MediaWiki Hook (PageContentSave). If there is an error that my script detects, how can I report it back to the user?

Ciencia Al Poder (talkcontribs)

Manual:Hooks/PageContentSave already provides an example. However, you can't display the error message in a box similar to the «Your edit has been saved».

Pulsargranular (talkcontribs)

Weird. I do exactly as shown in the example, but no message appears after saving the document. I checked the code gets executed.

$status->fatal(new RawMessage("Your Error Message Here!"));

does not print anything at all.

Ciencia Al Poder (talkcontribs)

Looking at the code, you should return false from that function in order to cancel the save.

Pulsargranular (talkcontribs)

Thank you very, very much. That helped! And thank you correcting the example. It is IMHO not very intuitive to set a status to fatal AND returning false. Anyways, thanks a lot, you made my day!

TheDJ (talkcontribs)

Wikipedia uses Extension:AbuseFilter for similar functionality. It's a bit more complex, with more options, but it's know to work and supported.