Bartosz Dziewoński has uploaded a new change for review.
https://gerrit.wikimedia.org/r/246271
Change subject: Add a change tag to cross-wiki uploads
......................................................................
Add a change tag to cross-wiki uploads
This is some bad code, I'm afraid.
Bug: T115328
Change-Id: If99e2f0b01afea2bb4ff680a9dfcc88c044d62bf
---
M includes/api/ApiUpload.php
M includes/api/i18n/en.json
M includes/api/i18n/qqq.json
M resources/src/mediawiki/mediawiki.Upload.js
4 files changed, 17 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/71/246271/1
diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php
index b621cb0..9fef92a 100644
--- a/includes/api/ApiUpload.php
+++ b/includes/api/ApiUpload.php
@@ -111,6 +111,16 @@
$result = $this->getContextResult();
if ( $result['result'] === 'Success' ) {
$result['imageinfo'] =
$this->mUpload->getImageInfo( $this->getResult() );
+
+ if (
+ $this->mParams['crosswikiuploadtag'] &&
+
$this->getRequest()->response()->getHeader( 'Access-Control-Allow-Origin' )
+ ) {
+ $revId = Title::makeTitle( NS_FILE,
$result['filename'] )->getLatestRevID( Title::GAID_FOR_UPDATE );
+ DeferredUpdates::addCallableUpdate(
function () use ( $revId ) {
+ ChangeTags::addTags(
'Cross-wiki upload', null, $revId );
+ } );
+ }
}
} catch ( UploadStashException $e ) { // XXX: don't spam
exception log
$this->handleStashException( $e );
@@ -798,6 +808,7 @@
'leavemessage' => false,
'statuskey' => null,
'checkstatus' => false,
+ 'crosswikiuploadtag' => false,
);
return $params;
diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json
index 90d7fa7..b69de60 100644
--- a/includes/api/i18n/en.json
+++ b/includes/api/i18n/en.json
@@ -1328,6 +1328,7 @@
"apihelp-upload-param-leavemessage": "If asyncdownload is used, leave a
message on the user talk page if finished.",
"apihelp-upload-param-statuskey": "Fetch the upload status for this
file key (upload by URL).",
"apihelp-upload-param-checkstatus": "Only fetch the upload status for
the given file key.",
+ "apihelp-upload-param-crosswikiuploadtag": "<span
class=\"apihelp-flag-internal\"><strong>Internal.</strong> Used to mark
cross-wiki uploads.</span>",
"apihelp-upload-example-url": "Upload from a URL.",
"apihelp-upload-example-filekey": "Complete an upload that failed due
to warnings.",
diff --git a/includes/api/i18n/qqq.json b/includes/api/i18n/qqq.json
index 9710e16..589a0f3 100644
--- a/includes/api/i18n/qqq.json
+++ b/includes/api/i18n/qqq.json
@@ -1236,6 +1236,7 @@
"apihelp-upload-param-leavemessage":
"{{doc-apihelp-param|upload|leavemessage}}",
"apihelp-upload-param-statuskey":
"{{doc-apihelp-param|upload|statuskey}}",
"apihelp-upload-param-checkstatus":
"{{doc-apihelp-param|upload|checkstatus}}",
+ "apihelp-upload-param-crosswikiuploadtag":
"{{doc-apihelp-param|upload|crosswikiuploadtag}}",
"apihelp-upload-example-url": "{{doc-apihelp-example|upload}}",
"apihelp-upload-example-filekey": "{{doc-apihelp-example|upload}}",
"apihelp-userrights-description":
"{{doc-apihelp-description|userrights}}",
diff --git a/resources/src/mediawiki/mediawiki.Upload.js
b/resources/src/mediawiki/mediawiki.Upload.js
index 1432912..ccba1c3 100644
--- a/resources/src/mediawiki/mediawiki.Upload.js
+++ b/resources/src/mediawiki/mediawiki.Upload.js
@@ -248,6 +248,8 @@
return this.api.upload( this.getFile(), {
watchlist: ( this.getWatchlist() ) ? 1 : undefined,
comment: this.getComment(),
+ // The API will check whether this is really a
cross-wiki upload
+ crosswikiuploadtag: true,
filename: this.getFilename(),
text: this.getText()
} ).then( function ( result ) {
@@ -317,6 +319,8 @@
return finishStash( {
watchlist: ( upload.getWatchlist() ) ? 1 :
undefined,
comment: upload.getComment(),
+ // The API will check whether this is really a
cross-wiki upload
+ crosswikiuploadtag: true,
filename: upload.getFilename(),
text: upload.getText()
} ).then( function ( result ) {
--
To view, visit https://gerrit.wikimedia.org/r/246271
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If99e2f0b01afea2bb4ff680a9dfcc88c044d62bf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits