Aaron Schulz has uploaded a new change for review.

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

Change subject: Avoid image table updates on file upload failure
......................................................................

Avoid image table updates on file upload failure

* If the publish() call did not really do anything, then there is
  no use in saving the page and file DB records. Previously the
  user would get an error but the description page would be made.

bug: 64071
Change-Id: I1959f8c1ef33dbd1b238f6020117d2862d4b0fd3
(cherry picked from commit 17480be012a9b0f331ff776832ddf865595f13e7)
---
M includes/filerepo/file/LocalFile.php
1 file changed, 8 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/52/127652/1

diff --git a/includes/filerepo/file/LocalFile.php 
b/includes/filerepo/file/LocalFile.php
index eb55e82..f9ab7b7 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -1159,16 +1159,19 @@
                // Trim spaces on user supplied text
                $comment = trim( $comment );
 
-               // truncate nicely or the DB will do it for us
+               // Truncate nicely or the DB will do it for us
                // non-nicely (dangling multi-byte chars, non-truncated version 
in cache).
                $comment = $wgContLang->truncate( $comment, 255 );
                $this->lock(); // begin
                $status = $this->publish( $srcPath, $flags, $options );
 
-               if ( $status->successCount > 0 ) {
-                       # Essentially we are displacing any existing current 
file and saving
-                       # a new current file at the old location. If just the 
first succeeded,
-                       # we still need to displace the current DB entry and 
put in a new one.
+               if ( $status->successCount >= 2 ) {
+                       // There will be a copy+(one of move,copy,store).
+                       // The first succeeding does not commit us to updating 
the DB
+                       // since it simply copied the current version to a 
timestamped file name.
+                       // It is only *preferable* to avoid leaving such files 
orphaned.
+                       // Once the second operation goes through, then the 
current version was
+                       // updated and we must therefore update the DB too.
                        if ( !$this->recordUpload2( $status->value, $comment, 
$pageText, $props, $timestamp, $user ) ) {
                                $status->fatal( 'filenotfound', $srcPath );
                        }

-- 
To view, visit https://gerrit.wikimedia.org/r/127652
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1959f8c1ef33dbd1b238f6020117d2862d4b0fd3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.24wmf1
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to