https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112151
Revision: 112151
Author: catrope
Date: 2012-02-22 21:24:10 +0000 (Wed, 22 Feb 2012)
Log Message:
-----------
1.19wmf1: Fix the UploadStash hack in thumb.php so it works with the FileRepo
refactoring. This is already live.
* FSRepo constructor needs real file paths, but getZonePath() returns mwstore
paths. Pass in data from $wgLocalFileRepo instead. This is a hack but whatever
* FSRepo constructor requires a 'name' key, pass one. This caused a notice in
1.18wmf1 but causes an exception in 1.19wmf1
* For building $path, use the 'public' zone of the fake repo rather than the
'temp' zone of the real repo. They have the same FS paths, so they were
identical in 1.18wmf1 but the mwstore URLs returned in 1.19wmf1 are different
* Pass a Title object with $strippedName into the UnregisteredLocalFile
constructor so $this->name is set to $strippedName rather than $fileName, which
is needed for hash paths to be computed correctly (the hash path for
20120222132345!foo.png should be based on md5('foo.png'), not on
md5('20120222132345!foo.png') )
Modified Paths:
--------------
branches/wmf/1.19wmf1/thumb.php
Modified: branches/wmf/1.19wmf1/thumb.php
===================================================================
--- branches/wmf/1.19wmf1/thumb.php 2012-02-22 21:23:28 UTC (rev 112150)
+++ branches/wmf/1.19wmf1/thumb.php 2012-02-22 21:24:10 UTC (rev 112151)
@@ -125,19 +125,22 @@
// Dirty, horrible, evil hack. We need to create a repo with
the right zone paths for this to work
$localRepo = RepoGroup::singleton()->getLocalRepo();
+ global $wgLocalFileRepo;
$repo = new FSRepo(
- array( 'directory' => $localRepo->getZonePath( 'temp' ),
- 'url' => $localRepo->getZoneUrl( 'temp' ),
- 'thumbDir'=> $localRepo->getZonePath( 'thumb' ) .
'/temp',
- 'thumbUrl' => $localRepo->getZoneUrl( 'thumb' ) .
'/temp'
+ array( 'directory' => $wgLocalFileRepo['directory'] .
'/temp',
+ 'url' => $wgLocalFileRepo['url'] . '/temp',
+ 'thumbDir'=> $wgLocalFileRepo['thumbDir'] . '/temp',
+ 'thumbUrl' => $wgLocalFileRepo['thumbUrl'] . '/temp',
+ 'name' => 'UploadStashHackery',
)
);
// $fileName can be like timestamp!name , strip the timestamp!
part
$parts = explode( '!', $fileName, 2 );
$strippedName = isset( $parts[1] ) ? $parts[1] : $fileName;
- $path = $localRepo->getZonePath( 'temp' ) . '/' .
RepoGroup::singleton()->getLocalRepo()->getHashPath( $strippedName ) .
$fileName;
- $img = new UnregisteredLocalFile( false, $repo, $path, false );
+ $path = $repo->getZonePath( 'public' ) . '/' .
RepoGroup::singleton()->getLocalRepo()->getHashPath( $strippedName ) .
$fileName;
+ // Need to pass in $strippedName as a Title object so hash
paths are computed correctly
+ $img = new UnregisteredLocalFile( Title::makeTitle( NS_FILE,
$strippedName ), $repo, $path, false );
} else {
$img = wfLocalFile( $fileName );
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs