mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Linter
synced 2024-11-23 23:44:17 +00:00
Delete linter rows when pages are deleted
Bug: T151281 Change-Id: I3b113d0729b288683d9bc6c2f552b99ed2890f5c
This commit is contained in:
parent
06671d2034
commit
70cc3ac190
|
@ -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"
|
||||
|
|
|
@ -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( [] );
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue