// Cache auth token information to avoid RTTs
if ( !empty( $config['cacheAuthInfo'] ) ) {
if ( PHP_SAPI === 'cli' ) {
- $this->srvCache = wfGetMainCache(); // preferrably memcached
+ // Preferrably memcached
+ $this->srvCache = ObjectCache::getLocalClusterInstance();
} else {
- try { // look for APC, XCache, WinCache, ect...
- $this->srvCache = ObjectCache::newAccelerator( array() );
- } catch ( Exception $e ) {
- }
+ // Look for APC, XCache, WinCache, ect...
+ $this->srvCache = ObjectCache::newAccelerator( CACHE_NONE );
}
+ } else {
+ $this->srvCache = new EmptyBagOStuff();
}
- $this->srvCache = $this->srvCache ?: new EmptyBagOStuff();
}
public function getFeatures() {
}
$sha1Hash = wfBaseConvert( sha1( $params['content'] ), 16, 36, 31 );
- $contentType = $this->getContentType( $params['dst'], $params['content'], null );
+ $contentType = isset( $params['headers']['content-type'] )
+ ? $params['headers']['content-type']
+ : $this->getContentType( $params['dst'], $params['content'], null );
$reqs = array( array(
'method' => 'PUT',
return $status;
}
$sha1Hash = wfBaseConvert( $sha1Hash, 16, 36, 31 );
- $contentType = $this->getContentType( $params['dst'], null, $params['src'] );
+ $contentType = isset( $params['headers']['content-type'] )
+ ? $params['headers']['content-type']
+ : $this->getContentType( $params['dst'], null, $params['src'] );
$handle = fopen( $params['src'], 'rb' );
if ( $handle === false ) { // source doesn't exist?
return $objHdrs; // failed
}
+ // Find prior custom HTTP headers
+ $postHeaders = $this->getCustomHeaders( $objHdrs );
+ // Find prior metadata headers
+ $postHeaders += $this->getMetadataHeaders( $objHdrs );
+
$status = Status::newGood();
/** @noinspection PhpUnusedLocalVariableInspection */
$scopeLockS = $this->getScopedFileLocks( array( $path ), LockManager::LOCK_UW, $status );
$hash = $tmpFile->getSha1Base36();
if ( $hash !== false ) {
$objHdrs['x-object-meta-sha1base36'] = $hash;
+ // Merge new SHA1 header into the old ones
+ $postHeaders['x-object-meta-sha1base36'] = $hash;
list( $srcCont, $srcRel ) = $this->resolveStoragePathReal( $path );
- list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->http->run( array(
+ list( $rcode ) = $this->http->run( array(
'method' => 'POST',
'url' => $this->storageUrl( $auth, $srcCont, $srcRel ),
- 'headers' => $this->authTokenHeaders( $auth ) + $objHdrs
+ 'headers' => $this->authTokenHeaders( $auth ) + $postHeaders
) );
if ( $rcode >= 200 && $rcode <= 299 ) {
$this->deleteFileCache( $path );