mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Nuke
synced 2024-12-18 02:50:39 +00:00
Queue deletion job instead of trying to delete the pages
This would make running Special:Nuke much faster and avoid production errors due to timeout. Bug: T188679 Bug: T212690 Change-Id: I59d99068dd4d663261a5a5d0180105889fca66a2
This commit is contained in:
parent
7a49924836
commit
92c459552c
|
@ -21,6 +21,7 @@
|
|||
"nuke-maxpages": "Maximum number of pages:",
|
||||
"nuke-editby": "Created by [[Special:Contributions/$1|{{GENDER:$1|$1}}]]",
|
||||
"nuke-deleted": "Page '''$1''' has been deleted.",
|
||||
"nuke-deletion-queued": "Page '''$1''' has been queued for deletion.",
|
||||
"nuke-not-deleted": "Page [[:$1]] '''could not''' be deleted.",
|
||||
"nuke-delete-more": "[[Special:Nuke|Delete more pages]]",
|
||||
"nuke-pattern": "SQL LIKE pattern (e.g. %) for the page name:",
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
"nuke-maxpages": "Used as label for \"nuke limit\" input box.",
|
||||
"nuke-editby": "This message is followed by {{msg-mw|Comma-separator}} and {{msg-mw|Nuke-viewchanges}}.\n\nParameters:\n* $1 - a username",
|
||||
"nuke-deleted": "Used as success result of deletion. Parameters:\n* $1 - page title\nSee also:\n* {{msg-mw|Nuke-not-deleted}}",
|
||||
"nuke-deletion-queued": "Used when the page is queued for deletion. Parameters:\n* $1 - page title\nSee also:\n* {{msg-mw|Nuke-deleted}}",
|
||||
"nuke-not-deleted": "Used as failure result of deletion. Parameters:\n* $1 - page title\nSee also:\n* {{msg-mw|Nuke-deleted}}",
|
||||
"nuke-delete-more": "Used at the bottom of the Nuke (mass deletion) result page.",
|
||||
"nuke-pattern": "Used as label for \"nuke pattern\" input box.",
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace MediaWiki\Extension\Nuke;
|
||||
|
||||
use DeletePageJob;
|
||||
use FileDeleteForm;
|
||||
use Html;
|
||||
use HTMLForm;
|
||||
|
@ -14,7 +15,6 @@ use Title;
|
|||
use User;
|
||||
use UserBlockedError;
|
||||
use UserNamePrefixSearch;
|
||||
use WikiPage;
|
||||
use Xml;
|
||||
|
||||
class SpecialNuke extends SpecialPage {
|
||||
|
@ -343,6 +343,7 @@ class SpecialNuke extends SpecialPage {
|
|||
*/
|
||||
protected function doDelete( array $pages, $reason ) {
|
||||
$res = [];
|
||||
$jobs = [];
|
||||
$user = $this->getUser();
|
||||
|
||||
$services = MediaWikiServices::getInstance();
|
||||
|
@ -379,17 +380,29 @@ class SpecialNuke extends SpecialPage {
|
|||
$user
|
||||
);
|
||||
} else {
|
||||
$status = WikiPage::factory( $title )
|
||||
->doDeleteArticleReal( $reason, $user );
|
||||
$job = new DeletePageJob( [
|
||||
'namespace' => $title->getNamespace(),
|
||||
'title' => $title->getId(),
|
||||
'reason' => $reason,
|
||||
'userId' => $user->getId()
|
||||
] );
|
||||
$jobs[] = $job;
|
||||
$status = 'job';
|
||||
}
|
||||
|
||||
if ( $status->isOK() ) {
|
||||
if ( $status == 'job' ) {
|
||||
$res[] = $this->msg( 'nuke-deletion-queued', $title->getPrefixedText() )->parse();
|
||||
} elseif ( $status->isOK() ) {
|
||||
$res[] = $this->msg( 'nuke-deleted', $title->getPrefixedText() )->parse();
|
||||
} else {
|
||||
$res[] = $this->msg( 'nuke-not-deleted', $title->getPrefixedText() )->parse();
|
||||
}
|
||||
}
|
||||
|
||||
if ( $jobs ) {
|
||||
MediaWikiServices::getInstance()->getJobQueueGroup()->push( $jobs );
|
||||
}
|
||||
|
||||
$this->getOutput()->addHTML(
|
||||
"<ul>\n<li>" .
|
||||
implode( "</li>\n<li>", $res ) .
|
||||
|
|
Loading…
Reference in a new issue