r77266 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77265‎ | r77266 | r77267 >
Date:23:27, 24 November 2010
Author:catrope
Status:ok (Comments)
Tags:
Comment:
1.16wmf4: Commit live hack for temporary thumbnail support in thumb.php . This should be reengineered properly before being put in trunk
Modified paths:
  • /branches/wmf/1.16wmf4/thumb.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.16wmf4/thumb.php
@@ -47,6 +47,9 @@
4848 $isOld = (isset( $params['archived'] ) && $params['archived']);
4949 unset( $params['archived'] );
5050
 51+ // Is this a thumb of a temp file?
 52+ $isTemp = (isset( $params['temp'] ) && $params['temp']);
 53+
5154 // Some basic input validation
5255 $fileName = strtr( $fileName, '\\/', '__' );
5356
@@ -64,13 +67,23 @@
6568 return;
6669 }
6770 $img = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $title, $fileName );
 71+ } else if ( $isTemp ) {
 72+ // Dirty, horrible, evil hack. We need to create a repo with the right zone paths for this to work
 73+ $localRepo = RepoGroup::singleton()->getLocalRepo();
 74+ $repo = new FSRepo( array( 'directory' => $localRepo->getZonePath( 'temp' ), 'url' => $localRepo->getZoneUrl( 'temp' ), 'thumbPath'=> $localRepo->getZonePath( 'thumb' ) . '/temp', 'thumbUrl' => $localRepo->getZoneUrl( 'thumb' ) . '/temp' ) );
 75+ // $fileName can be like timestamp!name , strip the timestamp! part
 76+ $parts = explode( '!', $fileName, 2 );
 77+ $strippedName = isset( $parts[1] ) ? $parts[1] : $fileName;
 78+ $path = $localRepo->getZonePath( 'temp' ) . '/' . RepoGroup::singleton()->getLocalRepo()->getHashPath( $strippedName ) . $fileName;
 79+ $img = new UnregisteredLocalFile( false, $repo, $path, false );
6880 } else {
6981 $img = wfLocalFile( $fileName );
7082 }
7183
7284 // Check permissions if there are read restrictions
7385 if ( !in_array( 'read', User::getGroupPermissions( array( '*' ) ), true ) ) {
74 - if ( !$img->getTitle()->userCanRead() ) {
 86+ // If we have a title, check that for read access. If not (stashed file), be paranoid and disallow
 87+ if ( !$img->getTitle() || !$img->getTitle()->userCanRead() ) {
7588 wfThumbError( 403, 'Access denied. You do not have permission to access ' .
7689 'the source file.' );
7790 return;

Follow-up revisions

RevisionCommit summaryAuthorDate
r78134Sync'ing r74494-r77266awjrichards19:22, 9 December 2010
r96827Commit live patch, not sure who wrote it. It fixes a bug from r77266, reappli...tstarling08:04, 12 September 2011
r975121.18wmf1 Merge r60970, r69199, r77266, r96827 (Some of the revisions from r81...reedy16:01, 19 September 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   20:17, 19 September 2011

I can't remember what uses this. UploadWizard or standard MW upload preview or such?

#Comment by Catrope (talk | contribs)   08:33, 20 September 2011

UploadStash uses this. The primary consumer of UploadStash is UploadWizard.

Status & tagging log