Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make summaries mandatory in MediaWiki?

Tags:

mediawiki

When editing/moving/deleting pages or blocking/unblocking users, I would like the summary field in each page that performs one of the above functions to be mandatory, so that motives behind one of the actions can be known more easily.

like image 761
monster1612 Avatar asked Oct 27 '25 12:10

monster1612


2 Answers

This is very well known to draw a lot of contributions away, but you can enforce it via a custom JavaScript or soft-force it by setting forceeditsummary to true in $wgDefaultUserOptions:

// in LocalSettings.php:
$wgDefaultUserOptions = [
    'forceeditsummary' => 1
];

With this option on, after hitting Save page without an edit summary, you have to hit Save page again to get the edit saved. A reminder to fill the edit summary is shown at the top of the page but the second save goes through anyway.

As I said above, experience shows that many edits get lost with this setting. If you think that people forget to save twice, rather than just refuse to fill edit summaries, you can use MediaWiki stylesheets to make the warning more visible, with something flashy like

#mw-missingsummary {
    background-color: #FFFFCC;
    color: #000000;
    border: 3px double #CC0000;
    margin: 0 0 1em;
    padding: 0.5em 1em;
}

Note that the default settings are used for unregistered users and users who have not customized their preferences only. Registered users are allowed to override the value at any time: Preferences → Editing → Prompt me when entering a blank edit summary.

like image 62
Nemo Avatar answered Oct 30 '25 10:10

Nemo


I just implemented this functionality in a project I work on. It works fine, and plays well with all the in-built features, ranging from very early MediaWiki versions to the current one from master branch (2015-12-13).

I put this in my LocalSettings.php:

function forceEditSummary($editor, $text, $section, &$error, $summary) {
    // Override the setting so far based on wpIgnoreBlankSummary form
    // variable, forceeditsummary user option and whether the page is the
    // editor’s own user or talk page:
    $editor->allowBlankSummary = false;
    return true; // continue processing
}

$wgHooks['EditFilter'][] = 'forceEditSummary';

MediaWiki:Missingsummary and MediaWiki:Missingcommentheader1 messages should be edited to be true (second submit will not go through anymore).

I used the EditFilter hook to set the allowBlankSummary member of the editor (EditPage object) and thus override previous decisions on whether the edit shall go through even with blank summary, or not. See the source code of EditPage class for details of the original settings.

For more options (and supplementary styling giving emphasis to the missingsummary message), read Nemo’s answer.

1 Where is the missingcommentheader message used? I see it in the code but I don’t know when $editor->section == 'new'. Probably a feature of MediaWiki I never use…

like image 42
Palec Avatar answered Oct 30 '25 09:10

Palec



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!