r97512 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97511‎ | r97512 | r97513 >
Date:16:01, 19 September 2011
Author:reedy
Status:ok
Tags:
Comment:
1.18wmf1 Merge r60970, r69199, r77266, r96827 (Some of the revisions from r81460)
Modified paths:
  • /branches/wmf/1.18wmf1/includes/filerepo/RepoGroup.php (modified) (history)
  • /branches/wmf/1.18wmf1/languages/LanguageConverter.php (modified) (history)
  • /branches/wmf/1.18wmf1/thumb.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/includes/filerepo/RepoGroup.php
@@ -30,7 +30,7 @@
3131 * @var RepoGroup
3232 */
3333 protected static $instance;
34 - const MAX_CACHE_SIZE = 1000;
 34+ const MAX_CACHE_SIZE = 5;
3535
3636 /**
3737 * Get a RepoGroup instance. At present only one instance of RepoGroup is
Index: branches/wmf/1.18wmf1/thumb.php
@@ -51,6 +51,9 @@
5252 $isOld = (isset( $params['archived'] ) && $params['archived']);
5353 unset( $params['archived'] );
5454
 55+ // Is this a thumb of a temp file?
 56+ $isTemp = ( isset( $params['temp'] ) && $params['temp'] );
 57+
5558 // Some basic input validation
5659 $fileName = strtr( $fileName, '\\/', '__' );
5760
@@ -70,13 +73,31 @@
7174 return;
7275 }
7376 $img = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $title, $fileName );
 77+ } else if ( $isTemp ) {
 78+ // Dirty, horrible, evil hack. We need to create a repo with the right zone paths for this to work
 79+ $localRepo = RepoGroup::singleton()->getLocalRepo();
 80+
 81+ $repo = new FSRepo(
 82+ array( 'directory' => $localRepo->getZonePath( 'temp' ),
 83+ 'url' => $localRepo->getZoneUrl( 'temp' ),
 84+ 'thumbDir'=> $localRepo->getZonePath( 'thumb' ) . '/temp',
 85+ 'thumbUrl' => $localRepo->getZoneUrl( 'thumb' ) . '/temp'
 86+ )
 87+ );
 88+
 89+ // $fileName can be like timestamp!name , strip the timestamp! part
 90+ $parts = explode( '!', $fileName, 2 );
 91+ $strippedName = isset( $parts[1] ) ? $parts[1] : $fileName;
 92+ $path = $localRepo->getZonePath( 'temp' ) . '/' . RepoGroup::singleton()->getLocalRepo()->getHashPath( $strippedName ) . $fileName;
 93+ $img = new UnregisteredLocalFile( false, $repo, $path, false );
7494 } else {
7595 $img = wfLocalFile( $fileName );
7696 }
7797
7898 // Check permissions if there are read restrictions
7999 if ( !in_array( 'read', User::getGroupPermissions( array( '*' ) ), true ) ) {
80 - if ( !$img->getTitle()->userCanRead() ) {
 100+ // If we have a title, check that for read access. If not (stashed file), be paranoid and disallow
 101+ if ( !$img->getTitle() || !$img->getTitle()->userCanRead() ) {
81102 wfThumbError( 403, 'Access denied. You do not have permission to access ' .
82103 'the source file.' );
83104 wfProfileOut( __METHOD__ );
Index: branches/wmf/1.18wmf1/languages/LanguageConverter.php
@@ -792,13 +792,14 @@
793793 if ( $this->mTablesLoaded ) {
794794 return;
795795 }
796 - global $wgMemc;
 796+ //global $wgMemc;
797797 wfProfileIn( __METHOD__ );
798798 $this->mTablesLoaded = true;
799799 $this->mTables = false;
800800 if ( $fromCache ) {
801801 wfProfileIn( __METHOD__ . '-cache' );
802 - $this->mTables = $wgMemc->get( $this->mCacheKey );
 802+ // $this->mTables = $wgMemc->get( $this->mCacheKey );
 803+ $this->mTables = apc_fetch( $this->mCacheKey );
803804 wfProfileOut( __METHOD__ . '-cache' );
804805 }
805806 if ( !$this->mTables
@@ -816,7 +817,8 @@
817818 $this->postLoadTables();
818819 $this->mTables[self::CACHE_VERSION_KEY] = true;
819820
820 - $wgMemc->set( $this->mCacheKey, $this->mTables, 43200 );
 821+ // $wgMemc->set($this->mCacheKey, $this->mTables, 43200);
 822+ apc_store( $this->mCacheKey, $this->mTables, 43200 );
821823 wfProfileOut( __METHOD__ . '-recache' );
822824 }
823825 wfProfileOut( __METHOD__ );

Follow-up revisions

RevisionCommit summaryAuthorDate
r111194MFT r97505, r97508, r97509, r97512, r99928reedy19:53, 10 February 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r60970backupmidom15:23, 12 January 2010
r69199Cache very few File objects in the RepoGroup cache, since massive DjVu metada...tstarling00:55, 9 July 2010
r772661.16wmf4: Commit live hack for temporary thumbnail support in thumb.php . Thi...catrope23:27, 24 November 2010
r81460Applied local patches for new WMF branchcatrope15:32, 3 February 2011
r96827Commit live patch, not sure who wrote it. It fixes a bug from r77266, reappli...tstarling08:04, 12 September 2011

Status & tagging log