// Process cache for container info
$this->containerStatCache = new ProcessCacheLRU( 300 );
// Cache auth token information to avoid RTTs
- if ( !empty( $config['cacheAuthInfo'] ) ) {
- if ( PHP_SAPI === 'cli' ) {
- // Preferrably memcached
- $this->srvCache = ObjectCache::getLocalClusterInstance();
- } else {
- // Look for APC, XCache, WinCache, ect...
- $this->srvCache = ObjectCache::getLocalServerInstance( CACHE_NONE );
- }
+ if ( !empty( $config['cacheAuthInfo'] ) && isset( $config['srvCache'] ) ) {
+ $this->srvCache = $config['srvCache'];
} else {
$this->srvCache = new EmptyBagOStuff();
}
return $status; // already there
} elseif ( $stat === null ) {
$status->fatal( 'backend-fail-internal', $this->name );
- wfDebugLog( 'SwiftBackend', __METHOD__ . ': cannot get container stat' );
+ $this->logger->error( __METHOD__ . ': cannot get container stat' );
return $status;
}
$status->fatal( 'backend-fail-usable', $params['dir'] );
} else {
$status->fatal( 'backend-fail-internal', $this->name );
- wfDebugLog( 'SwiftBackend', __METHOD__ . ': cannot get container stat' );
+ $this->logger->error( __METHOD__ . ': cannot get container stat' );
}
return $status;
$status->fatal( 'backend-fail-usable', $params['dir'] );
} else {
$status->fatal( 'backend-fail-internal', $this->name );
- wfDebugLog( 'SwiftBackend', __METHOD__ . ': cannot get container stat' );
+ $this->logger->error( __METHOD__ . ': cannot get container stat' );
}
return $status;
return $status; // ok, nothing to do
} elseif ( !is_array( $stat ) ) {
$status->fatal( 'backend-fail-internal', $this->name );
- wfDebugLog( 'SwiftBackend', __METHOD__ . ': cannot get container stat' );
+ $this->logger->error( __METHOD__ . ': cannot get container stat' );
return $status;
}
}
/** @noinspection PhpUnusedLocalVariableInspection */
- $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
- wfDebugLog( 'SwiftBackend', __METHOD__ . ": $path was not stored with SHA-1 metadata." );
+ $ps = $this->scopedProfileSection( __METHOD__ . "-{$this->name}" );
+ $this->logger->error( __METHOD__ . ": $path was not stored with SHA-1 metadata." );
$objHdrs['x-object-meta-sha1base36'] = false;
}
}
- wfDebugLog( 'SwiftBackend', __METHOD__ . ": unable to set SHA-1 metadata for $path" );
+ $this->logger->error( __METHOD__ . ": unable to set SHA-1 metadata for $path" );
return $objHdrs; // failed
}
return $dirs; // nothing more
}
- $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
+ $ps = $this->scopedProfileSection( __METHOD__ . "-{$this->name}" );
$prefix = ( $dir == '' ) ? null : "{$dir}/";
// Non-recursive: only list dirs right under $dir
if ( !empty( $params['topOnly'] ) ) {
$status = $this->objectListing( $fullCont, 'names', $limit, $after, $prefix, '/' );
if ( !$status->isOK() ) {
- throw new FileBackendError( "Iterator page I/O error: {$status->getMessage()}" );
+ throw new FileBackendError( "Iterator page I/O error." );
}
$objects = $status->value;
foreach ( $objects as $object ) { // files and directories
$status = $this->objectListing( $fullCont, 'names', $limit, $after, $prefix );
if ( !$status->isOK() ) {
- throw new FileBackendError( "Iterator page I/O error: {$status->getMessage()}" );
+ throw new FileBackendError( "Iterator page I/O error." );
}
$objects = $status->value;
return $files; // nothing more
}
- $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
+ $ps = $this->scopedProfileSection( __METHOD__ . "-{$this->name}" );
$prefix = ( $dir == '' ) ? null : "{$dir}/";
// $objects will contain a list of unfiltered names or CF_Object items
// Reformat this list into a list of (name, stat array or null) entries
if ( !$status->isOK() ) {
- throw new FileBackendError( "Iterator page I/O error: {$status->getMessage()}" );
+ throw new FileBackendError( "Iterator page I/O error." );
}
$objects = $status->value;
if ( empty( $params['allowOB'] ) ) {
// Cancel output buffering and gzipping if set
- wfResetOutputBuffers();
+ call_user_func( $this->obResetFunc );
}
$handle = fopen( 'php://output', 'wb' );
}
protected function doGetLocalCopyMulti( array $params ) {
+ /** @var TempFSFile[] $tmpFiles */
$tmpFiles = [];
$auth = $this->getAuthentication();
) );
// See http://s3.amazonaws.com/doc/s3-developer-guide/RESTAuthentication.html.
// Note: adding a newline for empty CanonicalizedAmzHeaders does not work.
- return wfAppendQuery(
- str_replace( '/swift/v1', '', // S3 API is the rgw default
- $this->storageUrl( $auth ) . $spath ),
- [
+ // Note: S3 API is the rgw default; remove the /swift/ URL bit.
+ return str_replace( '/swift/v1', '', $this->storageUrl( $auth ) . $spath ) .
+ '?' .
+ http_build_query( [
'Signature' => $signature,
'Expires' => $expires,
- 'AWSAccessKeyId' => $this->rgwS3AccessKey ]
- );
+ 'AWSAccessKeyId' => $this->rgwS3AccessKey
+ ] );
}
}
* @return StatusValue[]
*/
protected function doExecuteOpHandlesInternal( array $fileOpHandles ) {
+ /** @var $statuses StatusValue[] */
$statuses = [];
$auth = $this->getAuthentication();
// Split the HTTP requests into stages that can be done concurrently
$httpReqsByStage = []; // map of (stage => index => HTTP request)
foreach ( $fileOpHandles as $index => $fileOpHandle ) {
+ /** @var SwiftFileOpHandle $fileOpHandle */
$reqs = $fileOpHandle->httpOp;
// Convert the 'url' parameter to an actual URL using $auth
foreach ( $reqs as $stage => &$req ) {
if ( $rcode != 204 && $rcode !== 202 ) {
$status->fatal( 'backend-fail-internal', $this->name );
- wfDebugLog( 'SwiftBackend', __METHOD__ . ': unexpected rcode value (' . $rcode . ')' );
+ $this->logger->error( __METHOD__ . ': unexpected rcode value (' . $rcode . ')' );
}
return $status;
* @return array|bool|null False on 404, null on failure
*/
protected function getContainerStat( $container, $bypassCache = false ) {
- $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
+ $ps = $this->scopedProfileSection( __METHOD__ . "-{$this->name}" );
if ( $bypassCache ) { // purge cache
$this->containerStatCache->clear( $container );
if ( $code == 401 ) { // possibly a stale token
$this->srvCache->delete( $this->getCredsCacheKey( $this->swiftUser ) );
}
- wfDebugLog( 'SwiftBackend',
+ $this->logger->error(
"HTTP $code ($desc) in '{$func}' (given '" . FormatJson::encode( $params ) . "')" .
( $err ? ": $err" : "" )
);