if ( $be instanceof FileBackend ) {
// We don't need "latest" since objects are immutable and
// backends should at least have "read-after-create" consistency.
if ( $be instanceof FileBackend ) {
// We don't need "latest" since objects are immutable and
// backends should at least have "read-after-create" consistency.
* @return array A map from url to stored content. Failed results are not represented.
*/
public function batchFetchFromURLs( array $urls ) {
* @return array A map from url to stored content. Failed results are not represented.
*/
public function batchFetchFromURLs( array $urls ) {
foreach ( $urls as $url ) {
$be = FileBackendGroup::singleton()->backendFromPath( $url );
if ( $be instanceof FileBackend ) {
$pathsByBackend[$be->getName()][] = $url;
}
}
foreach ( $urls as $url ) {
$be = FileBackendGroup::singleton()->backendFromPath( $url );
if ( $be instanceof FileBackend ) {
$pathsByBackend[$be->getName()][] = $url;
}
}
foreach ( $pathsByBackend as $backendName => $paths ) {
$be = FileBackendGroup::singleton()->get( $backendName );
foreach ( $pathsByBackend as $backendName => $paths ) {
$be = FileBackendGroup::singleton()->get( $backendName );
$be = FileBackendGroup::singleton()->get( $backend );
if ( $be instanceof FileBackend ) {
// Get three random base 36 characters to act as shard directories
$be = FileBackendGroup::singleton()->get( $backend );
if ( $be instanceof FileBackend ) {
// Get three random base 36 characters to act as shard directories
- $rand = wfBaseConvert( mt_rand( 0, 46655 ), 10, 36, 3 );
+ $rand = Wikimedia\base_convert( mt_rand( 0, 46655 ), 10, 36, 3 );
// Make sure ID is roughly lexicographically increasing for performance
$id = str_pad( UIDGenerator::newTimestampedUID128( 32 ), 26, '0', STR_PAD_LEFT );
// Segregate items by wiki ID for the sake of bookkeeping
// Make sure ID is roughly lexicographically increasing for performance
$id = str_pad( UIDGenerator::newTimestampedUID128( 32 ), 26, '0', STR_PAD_LEFT );
// Segregate items by wiki ID for the sake of bookkeeping
? "/{$rand[0]}/{$rand[1]}/{$rand[2]}/{$id}" // keep directories small
: "/{$rand[0]}/{$rand[1]}/{$id}"; // container sharding is only 2-levels
? "/{$rand[0]}/{$rand[1]}/{$rand[2]}/{$id}" // keep directories small
: "/{$rand[0]}/{$rand[1]}/{$id}"; // container sharding is only 2-levels
- $be->prepare( array( 'dir' => dirname( $url ), 'noAccess' => 1, 'noListing' => 1 ) );
- if ( $be->create( array( 'dst' => $url, 'content' => $data ) )->isOK() ) {
+ $be->prepare( [ 'dir' => dirname( $url ), 'noAccess' => 1, 'noListing' => 1 ] );
+ if ( $be->create( [ 'dst' => $url, 'content' => $data ] )->isOK() ) {