/**
* @see FileBackend::__construct()
* Additional $config params include:
- * - srvCache : BagOStuff cache to APC/XCache or the like.
+ * - srvCache : BagOStuff cache to APC or the like.
* - wanCache : WANObjectCache object to use for persistent caching.
* - mimeCallback : Callback that takes (storage path, content, file system path) and
* returns the MIME type of the file or 'unknown/unknown'. The file
*/
public function __construct( array $config ) {
parent::__construct( $config );
- $this->mimeCallback = isset( $config['mimeCallback'] )
- ? $config['mimeCallback']
- : null;
+ $this->mimeCallback = $config['mimeCallback'] ?? null;
$this->srvCache = new EmptyBagOStuff(); // disabled by default
$this->memCache = WANObjectCache::newEmpty(); // disabled by default
$this->cheapCache = new ProcessCacheLRU( self::CACHE_CHEAP_SIZE );
unset( $params['latest'] ); // sanity
// Check that the specified temp file is valid...
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$ok = ( is_file( $tmpPath ) && filesize( $tmpPath ) == 0 );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$ok ) { // not present or not empty
$status->fatal( 'backend-fail-opentemp', $tmpPath );
$stat = $this->doGetFileStat( $params );
if ( is_array( $stat ) ) { // file exists
// Strongly consistent backends can automatically set "latest"
- $stat['latest'] = isset( $stat['latest'] ) ? $stat['latest'] : $latest;
+ $stat['latest'] = $stat['latest'] ?? $latest;
$this->cheapCache->set( $path, 'stat', $stat );
$this->setFileCache( $path, $stat ); // update persistent cache
if ( isset( $stat['sha1'] ) ) { // some backends store SHA-1 as metadata
protected function doGetFileContentsMulti( array $params ) {
$contents = [];
foreach ( $this->doGetLocalReferenceMulti( $params ) as $path => $fsFile ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$contents[$path] = $fsFile ? file_get_contents( $fsFile->getPath() ) : false;
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
return $contents;
$status = $this->newStatus();
// Always set some fields for subclass convenience
- $params['options'] = isset( $params['options'] ) ? $params['options'] : [];
- $params['headers'] = isset( $params['headers'] ) ? $params['headers'] : [];
+ $params['options'] = $params['options'] ?? [];
+ $params['headers'] = $params['headers'] ?? [];
// Don't stream it out as text/html if there was a PHP error
if ( ( empty( $params['headless'] ) || $params['headers'] ) && headers_sent() ) {
}
if ( is_array( $stat ) ) { // file exists
// Strongly consistent backends can automatically set "latest"
- $stat['latest'] = isset( $stat['latest'] ) ? $stat['latest'] : $latest;
+ $stat['latest'] = $stat['latest'] ?? $latest;
$this->cheapCache->set( $path, 'stat', $stat );
$this->setFileCache( $path, $stat ); // update persistent cache
if ( isset( $stat['sha1'] ) ) { // some backends store SHA-1 as metadata
$shards = [];
list( $digits, $base ) = $this->getContainerHashLevels( $container );
if ( $digits > 0 ) {
- $numShards = pow( $base, $digits );
+ $numShards = $base ** $digits;
for ( $index = 0; $index < $numShards; $index++ ) {
$shards[] = '.' . Wikimedia\base_convert( $index, 10, $base, $digits );
}