From: Brian Wolff Date: Wed, 17 Apr 2013 23:39:58 +0000 (-0300) Subject: Add identifying info (img_timestamp and img_sha1) to upload log. X-Git-Tag: 1.31.0-rc.0~19710 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=8c328d030fc1f7f;p=lhc%2Fweb%2Fwiklou.git 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 --- diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index 50444a7a13..07afffe3e8 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -110,6 +110,8 @@ production. * (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 eaa2b47550..2aa5c28e92 100644 --- a/includes/api/ApiQueryLogEvents.php +++ b/includes/api/ApiQueryLogEvents.php @@ -265,6 +265,11 @@ class ApiQueryLogEvents extends ApiQueryBase { $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 325c6739a2..932a1d4778 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -1275,9 +1275,27 @@ class LocalFile extends File { $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 @@ class LocalFile extends File { 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 ) ) {