Make rc_cur_id have proper value for upload log entries.
authorBrian Wolff <bawolff+wn@gmail.com>
Tue, 18 Jun 2013 00:11:44 +0000 (21:11 -0300)
committerBrian Wolff <bawolff+wn@gmail.com>
Tue, 18 Jun 2013 00:35:47 +0000 (21:35 -0300)
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
includes/filerepo/file/LocalFile.php

index 1b434d9..e98ed8e 100644 (file)
@@ -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
index b21b87a..12f24c5 100644 (file)
@@ -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