Unicornisaurous has uploaded a new change for review. https://gerrit.wikimedia.org/r/266181
Change subject: Add parameter to API modules to apply change tags to log entries ...................................................................... Add parameter to API modules to apply change tags to log entries This change adds support for tagging log entries for the block, import, managetags, and move API modules, using a 'tags' parameter. Bug: T97720 Change-Id: I9d75d2cece317a7704c4bc6d734ad3cafe24544e --- M includes/MovePage.php M includes/api/ApiBlock.php M includes/api/ApiImport.php M includes/api/ApiManageTags.php M includes/api/ApiMove.php M includes/api/i18n/en.json M includes/specials/SpecialBlock.php M includes/specials/SpecialImport.php 8 files changed, 60 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/81/266181/1 diff --git a/includes/MovePage.php b/includes/MovePage.php index fb0ca8c..b7e380d 100644 --- a/includes/MovePage.php +++ b/includes/MovePage.php @@ -223,12 +223,13 @@ * @param User $user * @param string $reason * @param bool $createRedirect + * @param array $changeTags Tags to apply to the entry in the move log * @return Status */ - public function move( User $user, $reason, $createRedirect ) { + public function move( User $user, $reason, $createRedirect, $changeTags = array() ) { global $wgCategoryCollation; - Hooks::run( 'TitleMove', array( $this->oldTitle, $this->newTitle, $user ) ); + Hooks::run( 'TitleMove', array( $this->oldTitle, $this->newTitle, $user ), $changeTags ); // If it is a file, move it first. // It is done before all other moving stuff is done because it's hard to revert. @@ -252,7 +253,8 @@ $protected = $this->oldTitle->isProtected(); // Do the actual move - $nullRevision = $this->moveToInternal( $user, $this->newTitle, $reason, $createRedirect ); + $nullRevision = $this->moveToInternal( $user, $this->newTitle, $reason, $createRedirect, + $changeTags ); // Refresh the sortkey for this row. Be careful to avoid resetting // cl_timestamp, which may disturb time-based lists on some sites. @@ -405,12 +407,13 @@ * @param string $reason The reason for the move * @param bool $createRedirect Whether to leave a redirect at the old title. Does not check * if the user has the suppressredirect right + * @param array $changeTags Change tags to apply to the entry in the move log * @return Revision the revision created by the move * @throws MWException */ - private function moveToInternal( User $user, &$nt, $reason = '', $createRedirect = true ) { + private function moveToInternal( User $user, &$nt, $reason = '', $createRedirect = true, + $changeTags = array() ) { global $wgContLang; - if ( $nt->exists() ) { $moveOverRedirect = true; $logType = 'move_redir'; @@ -563,6 +566,10 @@ $logid = $logEntry->insert(); $logEntry->publish( $logid ); + if ( count( $changeTags ) ) { + ChangeTags::addTags( $changeTags, null, null, $logid, null ); + } + return $nullRevision; } } diff --git a/includes/api/ApiBlock.php b/includes/api/ApiBlock.php index e3d73a2..b46279b 100644 --- a/includes/api/ApiBlock.php +++ b/includes/api/ApiBlock.php @@ -96,6 +96,7 @@ 'Reblock' => $params['reblock'], 'Watch' => $params['watchuser'], 'Confirm' => true, + 'Tags' => $params['tags'], ); $retval = SpecialBlock::processForm( $data, $this->getContext() ); @@ -154,6 +155,10 @@ 'allowusertalk' => false, 'reblock' => false, 'watchuser' => false, + 'tags' => array( + ApiBase::PARAM_TYPE => 'tags', + ApiBase::PARAM_ISMULTI => true, + ), ); } diff --git a/includes/api/ApiImport.php b/includes/api/ApiImport.php index f0ca6fe..8ceafc8 100644 --- a/includes/api/ApiImport.php +++ b/includes/api/ApiImport.php @@ -77,7 +77,8 @@ $importer, $isUpload, $params['interwikisource'], - $params['summary'] + $params['summary'], + $params['tags'] ); try { @@ -140,6 +141,10 @@ ApiBase::PARAM_TYPE => 'namespace' ), 'rootpage' => null, + 'tags' => array( + ApiBase::PARAM_TYPE => 'tags', + ApiBase::PARAM_ISMULTI => true, + ), ); } diff --git a/includes/api/ApiManageTags.php b/includes/api/ApiManageTags.php index 240d350..131311e 100644 --- a/includes/api/ApiManageTags.php +++ b/includes/api/ApiManageTags.php @@ -53,6 +53,12 @@ if ( $ret['success'] ) { $ret['logid'] = $status->value; } + + // Apply change tags to the log entry, if requested + if ( count( $params['tags'] ) && $status->value ) { + ChangeTags::addTags( $params['tags'], null, null, $status->value, null ); + } + $result->addValue( null, $this->getModuleName(), $ret ); } @@ -81,6 +87,10 @@ ApiBase::PARAM_TYPE => 'boolean', ApiBase::PARAM_DFLT => false, ), + 'tags' => array( + ApiBase::PARAM_TYPE => 'tags', + ApiBase::PARAM_ISMULTI => true, + ), ); } diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php index c38457e..7f35813 100644 --- a/includes/api/ApiMove.php +++ b/includes/api/ApiMove.php @@ -74,7 +74,8 @@ // Move the page $toTitleExists = $toTitle->exists(); - $status = $this->movePage( $fromTitle, $toTitle, $params['reason'], !$params['noredirect'] ); + $status = $this->movePage( $fromTitle, $toTitle, $params['reason'], !$params['noredirect'], + $params['tags'] ); if ( !$status->isOK() ) { $this->dieStatus( $status ); } @@ -145,10 +146,11 @@ * @param Title $from * @param Title $to * @param string $reason + * @param array $changeTags tags to apply to the entry in the move log * @param bool $createRedirect * @return Status */ - protected function movePage( Title $from, Title $to, $reason, $createRedirect ) { + protected function movePage( Title $from, Title $to, $reason, $createRedirect, $changeTags ) { $mp = new MovePage( $from, $to ); $valid = $mp->isValidMove(); if ( !$valid->isOK() ) { @@ -165,7 +167,7 @@ $createRedirect = true; } - return $mp->move( $this->getUser(), $reason, $createRedirect ); + return $mp->move( $this->getUser(), $reason, $createRedirect, $changeTags ); } /** @@ -237,7 +239,11 @@ 'nochange' ), ), - 'ignorewarnings' => false + 'ignorewarnings' => false, + 'tags' => array( + ApiBase::PARAM_TYPE => 'tags', + ApiBase::PARAM_ISMULTI => true, + ), ); } diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json index 2fb9a50..5f17fd9 100644 --- a/includes/api/i18n/en.json +++ b/includes/api/i18n/en.json @@ -31,9 +31,9 @@ "apihelp-block-param-allowusertalk": "Allow the user to edit their own talk page (depends on <var>[[mw:Manual:$wgBlockAllowsUTEdit|$wgBlockAllowsUTEdit]]</var>).", "apihelp-block-param-reblock": "If the user is already blocked, overwrite the existing block.", "apihelp-block-param-watchuser": "Watch the user's or IP address's user and talk pages.", + "apihelp-block-param-tags": "Change tags to apply to the entry in the block log.", "apihelp-block-example-ip-simple": "Block IP address <kbd>192.0.2.5</kbd> for three days with reason <kbd>First strike</kbd>.", "apihelp-block-example-user-complex": "Block user <kbd>Vandal</kbd> indefinitely with reason <kbd>Vandalism</kbd>, and prevent new account creation and email sending.", - "apihelp-checktoken-description": "Check the validity of a token from <kbd>[[Special:ApiHelp/query+tokens|action=query&meta=tokens]]</kbd>.", "apihelp-checktoken-param-type": "Type of token being tested.", "apihelp-checktoken-param-token": "Token to test.", @@ -212,6 +212,7 @@ "apihelp-import-param-templates": "For interwiki imports: import all included templates as well.", "apihelp-import-param-namespace": "Import to this namespace. Cannot be used together with <var>$1rootpage</var>.", "apihelp-import-param-rootpage": "Import as subpage of this page. Cannot be used together with <var>$1namespace</var>.", + "apihelp-import-param-tags": "Change tags to apply to the entry in the import log.", "apihelp-import-example-import": "Import [[meta:Help:ParserFunctions]] to namespace 100 with full history.", "apihelp-login-description": "Log in and get authentication cookies.\n\nIn the event of a successful log-in, the needed cookies will be included in the HTTP response headers. In the event of a failed log-in, further attempts may be throttled to limit automated password guessing attacks.", @@ -230,6 +231,7 @@ "apihelp-managetags-param-tag": "Tag to create, delete, activate or deactivate. For tag creation, the tag must not exist. For tag deletion, the tag must exist. For tag activation, the tag must exist and not be in use by an extension. For tag deactivation, the tag must be currently active and manually defined.", "apihelp-managetags-param-reason": "An optional reason for creating, deleting, activating or deactivating the tag.", "apihelp-managetags-param-ignorewarnings": "Whether to ignore any warnings that are issued during the operation.", + "apihelp-managetags-param-tags": "Change tags to apply to the entry in the tag managment log.", "apihelp-managetags-example-create": "Create a tag named <kbd>spam</kbd> with the reason <kbd>For use in edit patrolling</kbd>", "apihelp-managetags-example-delete": "Delete the <kbd>vandlaism</kbd> tag with the reason <kbd>Misspelt</kbd>", "apihelp-managetags-example-activate": "Activate a tag named <kbd>spam</kbd> with the reason <kbd>For use in edit patrolling</kbd>", @@ -247,6 +249,7 @@ "apihelp-move-param-unwatch": "Remove the page and the redirect from the current user's watchlist.", "apihelp-move-param-watchlist": "Unconditionally add or remove the page from the current user's watchlist, use preferences or do not change watch.", "apihelp-move-param-ignorewarnings": "Ignore any warnings.", + "apihelp-move-param-tags": "Change tags to apply to the entry in the move log.", "apihelp-move-example-move": "Move <kbd>Badtitle</kbd> to <kbd>Goodtitle</kbd> without leaving a redirect.", "apihelp-opensearch-description": "Search the wiki using the OpenSearch protocol.", diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index d198ea1..26c1e6a 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -820,7 +820,11 @@ $logId = $logEntry->insert(); $logEntry->publish( $logId ); - # Report to the user + if ( isset( $data['Tags'] ) && count( $data['Tags'] ) ) { + ChangeTags::addTags( $data['Tags'], null, null, $logId, null ); + } + + // Return the log ID return true; } diff --git a/includes/specials/SpecialImport.php b/includes/specials/SpecialImport.php index 0574dbc..39eab0a 100644 --- a/includes/specials/SpecialImport.php +++ b/includes/specials/SpecialImport.php @@ -537,14 +537,16 @@ private $mOriginalLogCallback = null; private $mOriginalPageOutCallback = null; private $mLogItemCount = 0; + private $logTags = array(); /** * @param WikiImporter $importer * @param bool $upload * @param string $interwiki * @param string|bool $reason + * @param array $tags Change tags to apply to the entry in the import log */ - function __construct( $importer, $upload, $interwiki, $reason = false ) { + function __construct( $importer, $upload, $interwiki, $reason = false, $tags = array() ) { $this->mOriginalPageOutCallback = $importer->setPageOutCallback( array( $this, 'reportPage' ) ); $this->mOriginalLogCallback = @@ -554,6 +556,7 @@ $this->mIsUpload = $upload; $this->mInterwiki = $interwiki; $this->reason = $reason; + $this->logTags = $tags; } function open() { @@ -630,6 +633,10 @@ $logid = $logEntry->insert(); $logEntry->publish( $logid ); + if ( count( $this->logTags ) ) { + ChangeTags::addTags( $this->logTags, null, null, $logid, null ); + } + $comment = $detail; // quick $dbw = wfGetDB( DB_MASTER ); $latest = $title->getLatestRevID(); -- To view, visit https://gerrit.wikimedia.org/r/266181 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9d75d2cece317a7704c4bc6d734ad3cafe24544e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Unicornisaurous <crazy...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits