jenkins-bot has submitted this change and it was merged.
Change subject: Add identifying info (img_timestamp and img_sha1) to upload log.
......................................................................
Add identifying info (img_timestamp and img_sha1) to upload log.
I came across people complaining that it was hard to associate
upload log events to actual images since img_timestamp could
be different from log_timestamp, and generally no unique id.
Well I was there I made uploads use the new logging system.
Change-Id: Icd8662ecb9eb0f6c0ff9841bdbd5736d6dd0d015
---
M RELEASE-NOTES-1.22
M includes/api/ApiQueryLogEvents.php
M includes/filerepo/file/LocalFile.php
3 files changed, 30 insertions(+), 3 deletions(-)
Approvals:
Anomie: Looks good to me, approved
jenkins-bot: Verified
diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22
index 50444a7..07afffe 100644
--- a/RELEASE-NOTES-1.22
+++ b/RELEASE-NOTES-1.22
@@ -110,6 +110,8 @@
* (bug 47219) Allow specifying change type of Wikipedia feed items
* prop=imageinfo now allows setting iiurlheight without setting iiurlwidth
* prop=info now adds the content model of the title.
+* New upload log entries will now contain information on the relavent
+ image (sha1 and timestamp).
=== Languages updated in 1.22===
diff --git a/includes/api/ApiQueryLogEvents.php
b/includes/api/ApiQueryLogEvents.php
index eaa2b47..2aa5c28 100644
--- a/includes/api/ApiQueryLogEvents.php
+++ b/includes/api/ApiQueryLogEvents.php
@@ -265,6 +265,11 @@
$vals[$type] = $vals2;
$params = null;
break;
+ case 'upload':
+ if ( isset( $params['img_timestamp'] ) ) {
+ $params['img_timestamp'] = wfTimestamp(
TS_ISO_8601, $params['img_timestamp'] );
+ }
+ break;
}
if ( !is_null( $params ) ) {
$logParams = array();
diff --git a/includes/filerepo/file/LocalFile.php
b/includes/filerepo/file/LocalFile.php
index 325c673..932a1d4 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -1275,9 +1275,27 @@
$wikiPage->setFile( $this );
# Add the log entry
- $log = new LogPage( 'upload' );
$action = $reupload ? 'overwrite' : 'upload';
- $logId = $log->addEntry( $action, $descTitle, $comment,
array(), $user );
+
+ $logEntry = new ManualLogEntry( 'upload', $action );
+ $logEntry->setPerformer( $user );
+ $logEntry->setComment( $comment );
+ $logEntry->setTarget( $descTitle );
+
+ // Allow people using the api to associate log entries with the
upload.
+ // Log has a timestamp, but sometimes different from upload
timestamp.
+ $logEntry->setParameters(
+ array(
+ 'img_sha1' => $this->sha1,
+ 'img_timestamp' => $timestamp,
+ )
+ );
+ // Note we keep $logId around since during new image
+ // creation, page doesn't exist yet, so log_page = 0
+ // but we want it to point to the page we're making,
+ // so we later modify the log entry.
+ $logId = $logEntry->insert();
+ $logEntry->publish( $logId );
wfProfileIn( __METHOD__ . '-edit' );
$exists = $descTitle->exists();
@@ -1285,10 +1303,12 @@
if ( $exists ) {
# Create a null revision
$latest = $descTitle->getLatestRevID();
+ $editSummary = LogFormatter::newFromEntry( $logEntry
)->getPlainActionText();
+
$nullRevision = Revision::newNullRevision(
$dbw,
$descTitle->getArticleID(),
- $log->getRcComment(),
+ $editSummary,
false
);
if ( !is_null( $nullRevision ) ) {
--
To view, visit https://gerrit.wikimedia.org/r/59766
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icd8662ecb9eb0f6c0ff9841bdbd5736d6dd0d015
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Brian Wolff <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Brian Wolff <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits