$watch = true;
}
+ if ( $this->mParams['tags'] ) {
+ $status = ChangeTags::canAddTagsAccompanyingChange( $this->mParams['tags'], $this->getUser() );
+ if ( !$status->isOK() ) {
+ $this->dieStatus( $status );
+ }
+ }
+
// No errors, no warnings: do the upload
if ( $this->mParams['async'] ) {
$progress = UploadBase::getSessionStatus( $this->getUser(), $this->mParams['filekey'] );
'filename' => $this->mParams['filename'],
'filekey' => $this->mParams['filekey'],
'comment' => $this->mParams['comment'],
+ 'tags' => $this->mParams['tags'],
'text' => $this->mParams['text'],
'watch' => $watch,
'session' => $this->getContext()->exportSession()
} else {
/** @var $status Status */
$status = $this->mUpload->performUpload( $this->mParams['comment'],
- $this->mParams['text'], $watch, $this->getUser() );
+ $this->mParams['text'], $watch, $this->getUser(), $this->mParams['tags'] );
if ( !$status->isGood() ) {
$error = $status->getErrorsArray();
'comment' => array(
ApiBase::PARAM_DFLT => ''
),
+ 'tags' => array(
+ ApiBase::PARAM_TYPE => 'tags',
+ ApiBase::PARAM_ISMULTI => true,
+ ),
'text' => array(
ApiBase::PARAM_TYPE => 'text',
),
"apihelp-upload-description": "Upload a file, or get the status of pending uploads.\n\nSeveral methods are available:\n* Upload file contents directly, using the <var>$1file</var> parameter.\n* Upload the file in pieces, using the <var>$1filesize</var>, <var>$1chunk</var>, and <var>$1offset</var> parameters.\n* Have the MediaWiki server fetch a file from a URL, using the <var>$1url</var> parameter.\n* Complete an earlier upload that failed due to warnings, using the <var>$1filekey</var> parameter.\nNote that the HTTP POST must be done as a file upload (i.e. using <code>multipart/form-data</code>) when sending the <var>$1file</var>.",
"apihelp-upload-param-filename": "Target filename.",
"apihelp-upload-param-comment": "Upload comment. Also used as the initial page text for new files if <var>$1text</var> is not specified.",
+ "apihelp-upload-param-tags": "Change tags to apply to the upload log entry and file page revision.",
"apihelp-upload-param-text": "Initial page text for new files.",
"apihelp-upload-param-watch": "Watch the page.",
"apihelp-upload-param-watchlist": "Unconditionally add or remove the page from the current user's watchlist, use preferences or do not change watch.",
"apihelp-upload-description": "{{doc-apihelp-description|upload}}",
"apihelp-upload-param-filename": "{{doc-apihelp-param|upload|filename}}",
"apihelp-upload-param-comment": "{{doc-apihelp-param|upload|comment}}",
+ "apihelp-upload-param-tags": "{{doc-apihelp-param|upload|tags}}",
"apihelp-upload-param-text": "{{doc-apihelp-param|upload|text}}",
"apihelp-upload-param-watch": "{{doc-apihelp-param|upload|watch}}",
"apihelp-upload-param-watchlist": "{{doc-apihelp-param|upload|watchlist}}",
$this->params['comment'],
$this->params['text'],
$this->params['watch'],
- $user
+ $user,
+ isset( $this->params['tags'] ) ? $this->params['tags'] : array()
);
if ( !$status->isGood() ) {
UploadBase::setSessionStatus(
$pageText = false;
}
+ $changeTags = $this->getRequest()->getVal( 'wpChangeTags' );
+ if ( is_null( $changeTags ) || $changeTags === '' ) {
+ $changeTags = array();
+ } else {
+ $changeTags = array_filter( array_map( 'trim', explode( ',', $changeTags ) ) );
+ }
+
+ if ( $changeTags ) {
+ $changeTagsStatus = ChangeTags::canAddTagsAccompanyingChange(
+ $changeTags, $this->getUser() );
+ if ( !$changeTagsStatus->isOK() ) {
+ $this->showUploadError( $this->getOutput()->parse( $changeTagsStatus->getWikiText() ) );
+
+ return;
+ }
+ }
+
$status = $this->mUpload->performUpload(
$this->mComment,
$pageText,
$this->mWatchthis,
- $this->getUser()
+ $this->getUser(),
+ $changeTags
);
if ( !$status->isGood() ) {