Send Mediawiki watchlist emails in diff format
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Polyfloyd 4dd8fae1da Move links to the wiki below the diff
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:21:50 +02:00
i18n Initial commit 2026-10-21 20:27:54 +02:00
src Move links to the wiki below the diff 2026-10-21 21:21:50 +02:00
tests/phpunit/unit Initial commit 2026-10-21 20:27:54 +02:00
.gitignore Initial commit 2026-10-21 20:27:54 +02:00
AGENTS.md Initial commit 2026-10-21 20:27:54 +02:00
composer.json Initial commit 2026-10-21 20:27:54 +02:00
COPYING Initial commit 2026-10-21 20:27:54 +02:00
extension.json Initial commit 2026-10-21 20:27:54 +02:00
README.md Move links to the wiki below the diff 2026-10-21 21:21:50 +02:00

DiffMail

Warning

This project is vibecoded: it was written by an AI coding agent with limited human review. Review the code before relying on it.

A MediaWiki extension that replaces the email sent when a page on a user's watchlist changes. Instead of only linking to the change, the email includes the change as a git style diff:

The Bitlair page Main Page has been changed on 21 October 2026 at 18:22 by Alice.
Summary: Fix opening hours

diff --git a/Main_Page b/Main_Page
index 8..9 100644
--- a/Main_Page
+++ b/Main_Page
@@ -7,7 +7,7 @@
 Line 7
 Line 8
 Line 9
-Open on Thursdays
+Open on Thursdays and Saturdays
 Line 11
 Line 12
 Line 13

View this change: https://bitlair.nl/index.php?title=Main_Page&diff=9&oldid=8
All changes since your last visit: https://bitlair.nl/index.php?title=Main_Page&diff=0&oldid=8
Current revision: https://bitlair.nl/Main_Page

Supports MediaWiki 1.43.

Installation

Add the package to composer.local.json:

{
  "require": {
    "bitlair/mediawiki-diffmail": "dev-main"
  },
  "repositories": [
    {
      "type": "vcs",
      "url": "https://git.bitlair.nl/bitlair/mediawiki-extensions-diffmail.git"
    }
  ]
}

Run composer update --no-dev and add to LocalSettings.php:

wfLoadExtension( 'DiffMail' );

Watchlist emails must be enabled, e.g. with $wgEnotifWatchlist = true;.

Configuration

Variable Default Description
$wgDiffMailMaxDiffSize 102400 Maximum size of the diff in bytes. Larger diffs are truncated.

Behaviour

  • Only edits and page creations of text pages get a diff. Moves, deletions, restores and non-text content models get MediaWiki's default email.
  • The default email is also sent if the recipient may not read the page or the revision text has been deleted, as the diff would reveal its content.
  • User talk page notifications ($wgEnotifUserTalk) and $wgUsersNotifiedOnAllChanges are not changed.
  • Emails are always personal, $wgEnotifImpersonal is ignored.
  • Emails are sent with quoted-printable encoding, so that diffs of long lines survive SMTP's line length limit.

How it works

MediaWiki 1.43 has no hook to change the contents of a watchlist email. The SendWatchlistEmailNotification hook is used to suppress the default email for each watcher and send our own in its place. The details of the change are read from the EmailNotification instance passed to the hook.

MediaWiki 1.44 introduced a new notifications framework that will eventually replace EmailNotification, so this will need to be revisited for the next LTS.

Tests

php tests/phpunit/phpunit.php extensions/DiffMail/tests/phpunit

Run from the MediaWiki installation directory.