[FileBackend] Clear persistent stat cache if it mislead streamFile().
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 18 Oct 2012 21:58:32 +0000 (14:58 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 18 Oct 2012 21:58:32 +0000 (14:58 -0700)
Change-Id: Ie02e9e0c56180d8cbd2507b795cd960f3ba84f33

includes/filebackend/FileBackendStore.php

index 3000d2d..39cfc2d 100644 (file)
@@ -834,6 +834,13 @@ abstract class FileBackendStore extends FileBackend {
                        $status = $this->doStreamFile( $params );
                        wfProfileOut( __METHOD__ . '-send-' . $this->name );
                        wfProfileOut( __METHOD__ . '-send' );
+                       if ( !$status->isOK() ) {
+                               // Per bug 41113, nasty things can happen if bad cache entries get
+                               // stuck in cache. It's also possible that this error can come up
+                               // with simple race conditions. Clear out the stat cache to be safe.
+                               $this->clearCache( array( $params['src'] ) );
+                               $this->deleteFileCache( $params['src'] );
+                       }
                } else {
                        $status->fatal( 'backend-fail-stream', $params['src'] );
                }