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-maxpages": "Maximum number of pages:",
|
||||||
"nuke-editby": "Created by [[Special:Contributions/$1|{{GENDER:$1|$1}}]]",
|
"nuke-editby": "Created by [[Special:Contributions/$1|{{GENDER:$1|$1}}]]",
|
||||||
"nuke-deleted": "Page '''$1''' has been deleted.",
|
"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-not-deleted": "Page [[:$1]] '''could not''' be deleted.",
|
||||||
"nuke-delete-more": "[[Special:Nuke|Delete more pages]]",
|
"nuke-delete-more": "[[Special:Nuke|Delete more pages]]",
|
||||||
"nuke-pattern": "SQL LIKE pattern (e.g. %) for the page name:",
|
"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-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-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-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-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-delete-more": "Used at the bottom of the Nuke (mass deletion) result page.",
|
||||||
"nuke-pattern": "Used as label for \"nuke pattern\" input box.",
|
"nuke-pattern": "Used as label for \"nuke pattern\" input box.",
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace MediaWiki\Extension\Nuke;
|
namespace MediaWiki\Extension\Nuke;
|
||||||
|
|
||||||
|
use DeletePageJob;
|
||||||
use FileDeleteForm;
|
use FileDeleteForm;
|
||||||
use Html;
|
use Html;
|
||||||
use HTMLForm;
|
use HTMLForm;
|
||||||
|
@ -14,7 +15,6 @@ use Title;
|
||||||
use User;
|
use User;
|
||||||
use UserBlockedError;
|
use UserBlockedError;
|
||||||
use UserNamePrefixSearch;
|
use UserNamePrefixSearch;
|
||||||
use WikiPage;
|
|
||||||
use Xml;
|
use Xml;
|
||||||
|
|
||||||
class SpecialNuke extends SpecialPage {
|
class SpecialNuke extends SpecialPage {
|
||||||
|
@ -343,6 +343,7 @@ class SpecialNuke extends SpecialPage {
|
||||||
*/
|
*/
|
||||||
protected function doDelete( array $pages, $reason ) {
|
protected function doDelete( array $pages, $reason ) {
|
||||||
$res = [];
|
$res = [];
|
||||||
|
$jobs = [];
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
|
|
||||||
$services = MediaWikiServices::getInstance();
|
$services = MediaWikiServices::getInstance();
|
||||||
|
@ -379,17 +380,29 @@ class SpecialNuke extends SpecialPage {
|
||||||
$user
|
$user
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$status = WikiPage::factory( $title )
|
$job = new DeletePageJob( [
|
||||||
->doDeleteArticleReal( $reason, $user );
|
'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();
|
$res[] = $this->msg( 'nuke-deleted', $title->getPrefixedText() )->parse();
|
||||||
} else {
|
} else {
|
||||||
$res[] = $this->msg( 'nuke-not-deleted', $title->getPrefixedText() )->parse();
|
$res[] = $this->msg( 'nuke-not-deleted', $title->getPrefixedText() )->parse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $jobs ) {
|
||||||
|
MediaWikiServices::getInstance()->getJobQueueGroup()->push( $jobs );
|
||||||
|
}
|
||||||
|
|
||||||
$this->getOutput()->addHTML(
|
$this->getOutput()->addHTML(
|
||||||
"<ul>\n<li>" .
|
"<ul>\n<li>" .
|
||||||
implode( "</li>\n<li>", $res ) .
|
implode( "</li>\n<li>", $res ) .
|
||||||
|
|
Loading…
Reference in a new issue