From c25bf70238bb1e60dbbb0b897a1bc5d1adbfdd6d Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Mon, 17 Jun 2013 21:11:44 -0300 Subject: [PATCH] Make rc_cur_id have proper value for upload log entries. Primary motivation here is to make Special:Recentchangelinked work correctly for uploads where the description page doesn't exist yet. (Previously it was mostly only showing reupload log entries) Mild downside to this approach is adding the recentchanges row is now in a different commit... Change-Id: I74c68b972c47c03066d3065e3748769a27a654fb --- RELEASE-NOTES-1.22 | 1 + includes/filerepo/file/LocalFile.php | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index 1b434d9d1e..e98ed8ec0e 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -150,6 +150,7 @@ production. 'pageid', 'page', 'title', and 'text' (e.g. if only passed 'summary'). A warning will instead be issued if 'title' is non-default, unless no props are requested. +* Special:Recentchangeslinked will now include upload log entries === API changes in 1.22 === * (bug 46626) xmldoublequote parameter was removed. Because of a bug, the diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index b21b87ab10..12f24c5725 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -1294,11 +1294,16 @@ class LocalFile extends File { // 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. + // For a similar reason, we avoid making an RC entry + // now and wait until the page exists. $logId = $logEntry->insert(); - $logEntry->publish( $logId ); - wfProfileIn( __METHOD__ . '-edit' ); $exists = $descTitle->exists(); + if ( $exists ) { + // Page exists, do RC entry now (otherwise we wait for later). + $logEntry->publish( $logId ); + } + wfProfileIn( __METHOD__ . '-edit' ); if ( $exists ) { # Create a null revision @@ -1336,16 +1341,20 @@ class LocalFile extends File { $content = ContentHandler::makeContent( $pageText, $descTitle ); $status = $wikiPage->doEditContent( $content, $comment, EDIT_NEW | EDIT_SUPPRESS_RC, false, $user ); - if ( isset( $status->value['revision'] ) ) { // XXX; doEdit() uses a transaction - $dbw->begin( __METHOD__ ); + $dbw->begin( __METHOD__ ); // XXX; doEdit() uses a transaction + // Now that the page exists, make an RC entry. + $logEntry->publish( $logId ); + if ( isset( $status->value['revision'] ) ) { $dbw->update( 'logging', array( 'log_page' => $status->value['revision']->getPage() ), array( 'log_id' => $logId ), __METHOD__ ); - $dbw->commit( __METHOD__ ); // commit before anything bad can happen } + $dbw->commit( __METHOD__ ); // commit before anything bad can happen } + + wfProfileOut( __METHOD__ . '-edit' ); # Save to cache and purge the squid -- 2.20.1