Merge "[FileRepo] Added hook to let us copy thumbnails into additional places as...
authorBrion VIBBER <brion@wikimedia.org>
Thu, 26 Apr 2012 22:56:05 +0000 (22:56 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 26 Apr 2012 22:56:05 +0000 (22:56 +0000)
1  2 
docs/hooks.txt
includes/filerepo/file/File.php

diff --combined docs/hooks.txt
@@@ -395,11 -395,6 +395,11 @@@ In this data array, the key-value-pair 
  required.
  &$apis: array of services
  
 +'ApiTokensGetTokenTypes': use this hook to extend action=tokens with new
 +token types.
 +&$tokenTypes: supported token types in format 'type' => callback function
 +used to retrieve this type of tokens.
 +
  'ArticleAfterFetchContent': after fetching content of an article from
  the database
  $article: the article (object) being loaded from the database
@@@ -904,6 -899,12 +904,12 @@@ $article: in case all revisions of the 
  $user: user who performed the deletion
  $reason: reason
  
+ 'FileTransformed': When a file is transformed and moved into storage
+ $file: reference to the File object
+ $thumb: the MediaTransformOutput object
+ $tmpThumbPath: The temporary file system path of the transformed file
+ $thumbPath: The permanent storage path of the transformed file
  'FileUpload': When a file upload occurs
  $file : Image object representing the file that was uploaded
  $reupload : Boolean indicating if there was a previously another image there or not (since 1.17)
@@@ -842,13 -842,6 +842,13 @@@ abstract class File 
                                }
                        }
  
 +                      // If the backend is ready-only, don't keep generating thumbnails
 +                      // only to return transformation errors, just return the error now.
 +                      if ( $this->repo->getReadOnlyReason() !== false ) {
 +                              $thumb = $this->transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags );
 +                              break;
 +                      }
 +
                        // Create a temp FS file with the same extension and the thumbnail
                        $thumbExt = FileBackend::extensionFromPath( $thumbPath );
                        $tmpFile = TempFSFile::factory( 'transform_', $thumbExt );
                                } else {
                                        $thumb = $this->transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags );
                                }
+                               // Give extensions a chance to do something with this thumbnail...
+                               wfRunHooks( 'FileTransformed', array( $this, $thumb, $tmpThumbPath, $thumbPath ) );
                        }
  
                        // Purge. Useful in the event of Core -> Squid connection failure or squid