From ee39f5f7c53af38b6b727294e88c901a83bcda14 Mon Sep 17 00:00:00 2001 From: Platonides Date: Wed, 29 Aug 2012 23:23:27 +0200 Subject: [PATCH] (Bug 38606) Set log_page on uploads to the page_id of its description page This change updates the log_page in a second step after performing the edit, which is not terribly elegant, but is very robust. Change-Id: I9015230df772d049b2879fb34914c68183f1da05 --- includes/filerepo/file/LocalFile.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index e849c8e2db..75b9d458c6 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -1151,7 +1151,7 @@ class LocalFile extends File { # Add the log entry $log = new LogPage( 'upload' ); $action = $reupload ? 'overwrite' : 'upload'; - $log->addEntry( $action, $descTitle, $comment, array(), $user ); + $logId = $log->addEntry( $action, $descTitle, $comment, array(), $user ); wfProfileIn( __METHOD__ . '-edit' ); if ( $descTitle->exists() ) { @@ -1169,6 +1169,8 @@ class LocalFile extends File { wfRunHooks( 'NewRevisionFromEditComplete', array( $wikiPage, $nullRevision, $latest, $user ) ); $wikiPage->updateRevisionOn( $dbw, $nullRevision ); } + $dbw->update( 'logging', array( 'log_page' => $descTitle->getArticleID() ), array( 'log_id' => $logId ), __METHOD__ ); + # Invalidate the cache for the description page $descTitle->invalidateCache(); $descTitle->purgeSquid(); @@ -1176,7 +1178,11 @@ class LocalFile extends File { # New file; create the description page. # There's already a log entry, so don't make a second RC entry # Squid and file cache for the description page are purged by doEdit. - $wikiPage->doEdit( $pageText, $comment, EDIT_NEW | EDIT_SUPPRESS_RC, false, $user ); + $status = $wikiPage->doEdit( $pageText, $comment, EDIT_NEW | EDIT_SUPPRESS_RC, false, $user ); + + if ( isset( $status->value['revision'] ) ) { + $dbw->update( 'logging', array( 'log_page' => $status->value['revision']->getPage() ), array( 'log_id' => $logId ), __METHOD__ ); + } } wfProfileOut( __METHOD__ . '-edit' ); -- 2.20.1