}
$url = $remote['url'];
+ if ( substr( $url, -4 ) !== '.git' ) {
+ $url .= '.git';
+ }
foreach( $this->viewers as $repo => $viewer ) {
$m = array();
$pattern = '#^' . $repo . '$#';
} else {
$this->mMaxTitles = $maxTitles;
}
+ $urlArr = array_unique( $urlArr ); // Remove duplicates
if ( count( $urlArr ) > $this->mMaxTitles ) {
$urlArr = array_slice( $urlArr, 0, $this->mMaxTitles );
}
wfProfileIn( __METHOD__ );
+ $urlArr = array_unique( $urlArr ); // Remove duplicates
$maxSocketsPerSquid = 8; // socket cap per Squid
$urlsPerSocket = 400; // 400 seems to be a good tradeoff, opening a socket takes a while
$socketsPerSquid = ceil( count( $urlArr ) / $urlsPerSocket );
socket_set_option( $conn, IPPROTO_IP, IP_MULTICAST_TTL,
$wgHTCPMulticastTTL );
+ $urlArr = array_unique( $urlArr ); // Remove duplicates
foreach ( $urlArr as $url ) {
if( !is_string( $url ) ) {
throw new MWException( 'Bad purge URL' );
* @ingroup FileRepo
*/
class RepoGroup {
-
/**
* @var LocalRepo
*/
* @var RepoGroup
*/
protected static $instance;
- const MAX_CACHE_SIZE = 1000;
+ const MAX_CACHE_SIZE = 500;
/**
* Get a RepoGroup instance. At present only one instance of RepoGroup is
&& empty( $options['private'] )
&& empty( $options['bypassCache'] ) )
{
- $useCache = true;
$time = isset( $options['time'] ) ? $options['time'] : '';
$dbkey = $title->getDBkey();
if ( isset( $this->cache[$dbkey][$time] ) ) {
wfDebug( __METHOD__.": got File:$dbkey from process cache\n" );
# Move it to the end of the list so that we can delete the LRU entry later
- $tmp = $this->cache[$dbkey];
- unset( $this->cache[$dbkey] );
- $this->cache[$dbkey] = $tmp;
+ $this->pingCache( $dbkey );
# Return the entry
return $this->cache[$dbkey][$time];
- } else {
- # Add a negative cache entry, may be overridden
- $this->trimCache();
- $this->cache[$dbkey][$time] = false;
- $cacheEntry =& $this->cache[$dbkey][$time];
}
+ $useCache = true;
} else {
$useCache = false;
}
# Check the local repo
$image = $this->localRepo->findFile( $title, $options );
- if ( $image ) {
- if ( $useCache ) {
- $cacheEntry = $image;
- }
- return $image;
- }
# Check the foreign repos
- foreach ( $this->foreignRepos as $repo ) {
- $image = $repo->findFile( $title, $options );
- if ( $image ) {
- if ( $useCache ) {
- $cacheEntry = $image;
+ if ( !$image ) {
+ foreach ( $this->foreignRepos as $repo ) {
+ $image = $repo->findFile( $title, $options );
+ if ( $image ) {
+ break;
}
- return $image;
}
}
- # Not found, do not override negative cache
- return false;
+
+ $image = $image ? $image : false; // type sanity
+ # Cache file existence or non-existence
+ if ( $useCache && ( !$image || $image->isCacheable() ) ) {
+ $this->trimCache();
+ $this->cache[$dbkey][$time] = $image;
+ }
+
+ return $image;
}
function findFiles( $inputItems ) {
}
}
+ /**
+ * Move a cache entry to the top (such as when accessed)
+ */
+ protected function pingCache( $key ) {
+ if ( isset( $this->cache[$key] ) ) {
+ $tmp = $this->cache[$key];
+ unset( $this->cache[$key] );
+ $this->cache[$key] = $tmp;
+ }
+ }
+
/**
* Limit cache memory
*/
/**
* Return either a MediaTransformError or placeholder thumbnail (if $wgIgnoreImageErrors)
- *
+ *
* @param $thumbPath string Thumbnail storage path
* @param $thumbUrl string Thumbnail URL
* @param $params Array
return false;
}
+ /**
+ * Check if this file object is small and can be cached
+ * @return boolean
+ */
+ public function isCacheable() {
+ return true;
+ }
+
/**
* Assert that $this->repo is set to a valid FileRepo instance
* @throws MWException
* @ingroup FileAbstraction
*/
class LocalFile extends File {
+ const CACHE_FIELD_MAX_LEN = 1000;
+
/**#@+
* @private
*/
);
if ( $dbw->affectedRows() == 0 ) {
- # (bug 34993) Note: $oldver can be empty here, if the previous
- # version of the file was broken. Allow registration of the new
- # version to continue anyway, because that's better than having
+ # (bug 34993) Note: $oldver can be empty here, if the previous
+ # version of the file was broken. Allow registration of the new
+ # version to continue anyway, because that's better than having
# an image that's not fixable by user operations.
$reupload = true;
return $this->sha1;
}
+ function isCacheable() {
+ $this->load();
+ return strlen( $this->metadata ) <= self::CACHE_FIELD_MAX_LEN; // avoid OOMs
+ }
+
/**
* Start a transaction and lock the image for update
* Increments a reference counter if the lock is already held