Delete linter rows when pages are deleted

Bug: T151281
Change-Id: I3b113d0729b288683d9bc6c2f552b99ed2890f5c
This commit is contained in:
Kunal Mehta 2016-11-22 11:15:32 -08:00
parent 06671d2034
commit 70cc3ac190
2 changed files with 24 additions and 1 deletions

View file

@ -23,7 +23,8 @@
},
"Hooks": {
"LoadExtensionSchemaUpdates": "MediaWiki\\Linter\\Hooks::onLoadExtensionSchemaUpdates",
"EditFormInitialText": "MediaWiki\\Linter\\Hooks::onEditFormInitialText"
"EditFormInitialText": "MediaWiki\\Linter\\Hooks::onEditFormInitialText",
"WikiPageDeletionUpdates": "MediaWiki\\Linter\\Hooks::onWikiPageDeletionUpdates"
},
"APIModules": {
"record-lint": "MediaWiki\\Linter\\ApiRecordLint"

View file

@ -20,8 +20,11 @@
namespace MediaWiki\Linter;
use Content;
use DatabaseUpdater;
use EditPage;
use MWCallableUpdate;
use WikiPage;
class Hooks {
/**
@ -62,4 +65,23 @@ class Hooks {
] );
$out->addModules( 'ext.linter.edit' );
}
/**
* Hook: WikiPageDeletionUpdates
*
* Remove entries from the linter table upon page deletion
*
* @param WikiPage $wikiPage
* @param Content $content
* @param array &$updates
*/
public static function onWikiPageDeletionUpdates( WikiPage $wikiPage,
Content $content, array &$updates
) {
$id = $wikiPage->getId();
$updates[] = new MWCallableUpdate( function() use ( $id ) {
$database = new Database( $id );
$database->setForPage( [] );
} );
}
}