Brian Wolff has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/59766


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(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/66/59766/1

diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22
index d1d9654..626d521 100644
--- a/RELEASE-NOTES-1.22
+++ b/RELEASE-NOTES-1.22
@@ -50,6 +50,8 @@
   longer be), and will no longer choke on booleans.
 * action=opensearch no longer silently ignores the format parameter.
 * action=opensearch now supports format=jsonfm.
+* 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 73dcea4..a85944d 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 b481e83..526f477 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: newchange
Gerrit-Change-Id: Icd8662ecb9eb0f6c0ff9841bdbd5736d6dd0d015
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Brian Wolff <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to