On Thu, Oct 20, 2011 at 2:39 PM, Brion Vibber brion@pobox.com wrote:
As Tim noted, the particular case in Special:Undelete is probably an example of old code using a lazy interface due to old assumptions, and should actually be changed to use a proper File reference, and have a method to call from the File object / via the FileRepo/FileBackend that wraps streaming output so it doesn't actually need to do a file checkout.
I went through all the public (stored in our svn) instances of StreamFile::stream aka wfStream:
./includes/specials/SpecialRevisiondelete.php:319: StreamFile::stream( $path );
Okay: We can use $oimage (an instance of File), which comes from newFromArchiveName().
./includes/specials/SpecialUndelete.php:1011: StreamFile::stream( $path );
Okay: showFile() contains the call. It is only called from a context with a File. It's not being passed in now, but that's easily changed.
./img_auth.php:102:StreamFile::stream( $filename, array( 'Cache-Control: private', 'Vary: Cookie' ) );
No File: $filename is derived from PATH_INFO, and a File is never created.
./thumb.php:127: StreamFile::stream( $thumbPath, $headers );
Okay: $thumbPath came from $img->getThumbPath($params), which will fetch a local copy.
./thumb.php:156: StreamFile::stream( $thumb->getPath(), $headers );
No Change: $thumb is an instance of MediaTransformOutput, not File. Its $thumb->getPath() returns the path to the file in the local filesystem which was written by File::transform(). This actually works as-is because the file doesn't get stored in the media store.
./extensions/ConfirmAccount/ConfirmAccount_body.php:396: wfStreamFile( $path );
No File: calls getZonePath and computes the filename itself. Note that it's not using the same hashing scheme as anything else, although it most closely resembles deleted files. Even though it is stored in the same place as media files, it cannot be accessed as if it were a File because the hashing is different. Probably should be accessing the FileBackend directly.
./extensions/ConfirmAccount/UserCredentials_body.php:199: wfStreamFile( $path );
No File: calls getZonePath and computes the filename itself. Note that it's not using the same hashing scheme as anything else, although it most closely resembles deleted files. Even though it is stored in the same place as media files, it cannot be accessed as if it were a File because the hashing is different. Probably should be accessing the FileBackend directly.
./extensions/ConfirmEdit/FancyCaptcha.class.php:196: wfStreamFile( $file );
No File: Has its own top-level directory and hashing level. Not suitable for access as a File. Probably should be accessing the FileBackend directly.