| Index: branches/wmf/1.18wmf1/includes/filerepo/RepoGroup.php |
| — | — | @@ -30,7 +30,7 @@ |
| 31 | 31 | * @var RepoGroup |
| 32 | 32 | */ |
| 33 | 33 | protected static $instance; |
| 34 | | - const MAX_CACHE_SIZE = 1000; |
| | 34 | + const MAX_CACHE_SIZE = 5; |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Get a RepoGroup instance. At present only one instance of RepoGroup is |
| Index: branches/wmf/1.18wmf1/thumb.php |
| — | — | @@ -51,6 +51,9 @@ |
| 52 | 52 | $isOld = (isset( $params['archived'] ) && $params['archived']); |
| 53 | 53 | unset( $params['archived'] ); |
| 54 | 54 | |
| | 55 | + // Is this a thumb of a temp file? |
| | 56 | + $isTemp = ( isset( $params['temp'] ) && $params['temp'] ); |
| | 57 | + |
| 55 | 58 | // Some basic input validation |
| 56 | 59 | $fileName = strtr( $fileName, '\\/', '__' ); |
| 57 | 60 | |
| — | — | @@ -70,13 +73,31 @@ |
| 71 | 74 | return; |
| 72 | 75 | } |
| 73 | 76 | $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 ); |
| 74 | 94 | } else { |
| 75 | 95 | $img = wfLocalFile( $fileName ); |
| 76 | 96 | } |
| 77 | 97 | |
| 78 | 98 | // Check permissions if there are read restrictions |
| 79 | 99 | 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() ) { |
| 81 | 102 | wfThumbError( 403, 'Access denied. You do not have permission to access ' . |
| 82 | 103 | 'the source file.' ); |
| 83 | 104 | wfProfileOut( __METHOD__ ); |
| Index: branches/wmf/1.18wmf1/languages/LanguageConverter.php |
| — | — | @@ -792,13 +792,14 @@ |
| 793 | 793 | if ( $this->mTablesLoaded ) { |
| 794 | 794 | return; |
| 795 | 795 | } |
| 796 | | - global $wgMemc; |
| | 796 | + //global $wgMemc; |
| 797 | 797 | wfProfileIn( __METHOD__ ); |
| 798 | 798 | $this->mTablesLoaded = true; |
| 799 | 799 | $this->mTables = false; |
| 800 | 800 | if ( $fromCache ) { |
| 801 | 801 | wfProfileIn( __METHOD__ . '-cache' ); |
| 802 | | - $this->mTables = $wgMemc->get( $this->mCacheKey ); |
| | 802 | + // $this->mTables = $wgMemc->get( $this->mCacheKey ); |
| | 803 | + $this->mTables = apc_fetch( $this->mCacheKey ); |
| 803 | 804 | wfProfileOut( __METHOD__ . '-cache' ); |
| 804 | 805 | } |
| 805 | 806 | if ( !$this->mTables |
| — | — | @@ -816,7 +817,8 @@ |
| 817 | 818 | $this->postLoadTables(); |
| 818 | 819 | $this->mTables[self::CACHE_VERSION_KEY] = true; |
| 819 | 820 | |
| 820 | | - $wgMemc->set( $this->mCacheKey, $this->mTables, 43200 ); |
| | 821 | + // $wgMemc->set($this->mCacheKey, $this->mTables, 43200); |
| | 822 | + apc_store( $this->mCacheKey, $this->mTables, 43200 ); |
| 821 | 823 | wfProfileOut( __METHOD__ . '-recache' ); |
| 822 | 824 | } |
| 823 | 825 | wfProfileOut( __METHOD__ ); |