Fix name of PoolCounter callback in thumb.php
authorBrian Wolff <bawolff+wn@gmail.com>
Thu, 5 Nov 2015 06:59:58 +0000 (23:59 -0700)
committerBrian Wolff <bawolff+wn@gmail.com>
Thu, 5 Nov 2015 07:16:56 +0000 (00:16 -0700)
The callback is named doCachedWork, not getCachedWork. The typo
made it so that if multiple people try to render a file at once,
MediaWiki would not check if the last person to go already did the
needed work.

This might not make as much difference as it would sound, as the
pool counter lock is for the entire file, not a specific size,
and I'm unsure if swift has an equivalent of "slave lag", where the
check to see if a cached version is available might happen before
the write is totally visible.

Also merge the fallback handler into the error handler, so we get
actually error messages reported.

Change-Id: I12d228961de39cffc3d492554d93e30bd741adc9

thumb.php

index c699bb1..34f641d 100644 (file)
--- a/thumb.php
+++ b/thumb.php
@@ -420,18 +420,15 @@ function wfGenerateThumbnail( File $file, array $params, $thumbName, $thumbPath
                                'doWork' => function () use ( $file, $params ) {
                                        return $file->transform( $params, File::RENDER_NOW );
                                },
-                               'getCachedWork' => function () use ( $file, $params, $thumbPath ) {
+                               'doCachedWork' => function () use ( $file, $params, $thumbPath ) {
                                        // If the worker that finished made this thumbnail then use it.
                                        // Otherwise, it probably made a different thumbnail for this file.
                                        return $file->getRepo()->fileExists( $thumbPath )
                                                ? $file->transform( $params, File::RENDER_NOW )
                                                : false; // retry once more in exclusive mode
                                },
-                               'fallback' => function () {
-                                       return wfMessage( 'generic-pool-error' )->parse();
-                               },
                                'error' => function ( Status $status ) {
-                                       return $status->getHTML();
+                                       return wfMessage( 'generic-pool-error' )->parse() . '<hr>' . $status->getHTML();
                                }
                        )
                );