jenkins-bot has submitted this change and it was merged.
Change subject: Hooks to extend pages retrieval and deletion
......................................................................
Hooks to extend pages retrieval and deletion
Bug: T115695
Change-Id: Ia9dc16b3a4a623ef213adbcf18f44b497f2d9f27
---
M Nuke_body.php
A docs/hooks.txt
2 files changed, 42 insertions(+), 1 deletion(-)
Approvals:
Mattflaschen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Nuke_body.php b/Nuke_body.php
index c95f569..eb035b3 100644
--- a/Nuke_body.php
+++ b/Nuke_body.php
@@ -292,6 +292,17 @@
);
}
+ // Allows other extensions to provide pages to be nuked that
don't use
+ // the recentchanges table the way mediawiki-core does
+ Hooks::run( 'NukeGetNewPages', array( $username, $pattern,
$namespace, $limit, &$pages ) );
+
+ // Re-enforcing the limit *after* the hook because other
extensions
+ // may add and/or remove pages. We need to make sure we don't
end up
+ // with more pages than $limit.
+ if ( count( $pages ) > $limit ) {
+ $pages = array_slice( $pages, 0, $limit );
+ }
+
return $pages;
}
@@ -307,8 +318,18 @@
foreach ( $pages as $page ) {
$title = Title::newFromText( $page );
- $file = $title->getNamespace() === NS_FILE ?
wfLocalFile( $title ) : false;
+ $deletionResult = false;
+ if ( !Hooks::run( 'NukeDeletePage', array( $title,
$reason, &$deletionResult ) ) ) {
+ if ( $deletionResult ) {
+ $res[] = wfMessage( 'nuke-deleted',
$title->getPrefixedText() )->parse();
+ } else {
+ $res[] = wfMessage( 'nuke-not-deleted',
$title->getPrefixedText() )->parse();
+ }
+ continue;
+ }
+
+ $file = $title->getNamespace() === NS_FILE ?
wfLocalFile( $title ) : false;
$permission_errors = $title->getUserPermissionsErrors(
'delete', $this->getUser() );
if ( $permission_errors !== array() ) {
diff --git a/docs/hooks.txt b/docs/hooks.txt
new file mode 100644
index 0000000..587d38b
--- /dev/null
+++ b/docs/hooks.txt
@@ -0,0 +1,20 @@
+hooks.txt
+
+This document describes the events triggered by the Nuke extension.
+
+For more information about events and hooks in general see
mediawiki/docs/hooks.txt in gerrit.
+
+==Events and parameters==
+
+'NukeGetNewPages': After searching for pages to delete. Can be used to add and
remove pages.
+$username: the username filter specified by the user
+$pattern: the pattern filter specified by the user
+$namespace: the namespace filter specified by the user
+$limit: the limit filter specified by the user
+&$pages: list of pages title already retrieved
+
+'NukeDeletePage': Allows other extensions to handle the deletion of titles.
+Return true to let Nuke handle the deletion or false if it was already handled
in the hook.
+$title: title to delete
+$reason: reason given by the user for deletion
+&$deletionResult: Whether the deletion was successful or not
--
To view, visit https://gerrit.wikimedia.org/r/255981
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia9dc16b3a4a623ef213adbcf18f44b497f2d9f27
Gerrit-PatchSet: 8
Gerrit-Project: mediawiki/extensions/Nuke
Gerrit-Branch: master
Gerrit-Owner: Sbisson <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: Sbisson <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits