57 return MediaWikiServices::getInstance()
58 ->getExternalStoreFactory()
59 ->getStoreObject( $proto,
$params );
71 $parts = explode(
'://', $url, 2 );
72 if ( count( $parts ) != 2 ) {
76 list( $proto, $path ) = $parts;
81 $store = self::getStoreObject( $proto,
$params );
82 if ( $store ===
false ) {
86 return $store->fetchFromURL( $url );
99 foreach (
$urls as $url ) {
100 $scheme = parse_url( $url, PHP_URL_SCHEME );
102 $batches[$scheme][] = $url;
106 foreach ( $batches as $proto => $batchedUrls ) {
107 $store = self::getStoreObject( $proto );
108 if ( $store ===
false ) {
111 $retval += $store->batchFetchFromURLs( $batchedUrls );
116 foreach ( $missing as $url ) {
136 $parts = explode(
'://', $url, 2 );
137 if ( count( $parts ) != 2 ) {
141 list( $proto, $path ) = $parts;
146 $store = self::getStoreObject( $proto,
$params );
147 if ( $store ===
false ) {
150 return $store->store( $path, $data );
185 while ( count( $tryStores ) > 0 ) {
186 $index = mt_rand( 0, count( $tryStores ) - 1 );
187 $storeUrl = $tryStores[$index];
188 wfDebug( __METHOD__ .
": trying $storeUrl\n" );
189 list( $proto, $path ) = explode(
'://', $storeUrl, 2 );
190 $store = self::getStoreObject( $proto,
$params );
191 if ( $store ===
false ) {
192 throw new MWException(
"Invalid external storage protocol - $storeUrl" );
196 if ( $store->isReadOnly( $path ) ) {
199 $url = $store->store( $path, $data );
200 if ( strlen( $url ) ) {
203 $msg =
'operation failed';
205 }
catch ( Exception $error ) {
206 $msg =
'caught exception';
209 unset( $tryStores[$index] );
210 $tryStores = array_values( $tryStores );
212 "Unable to store text to external storage $storeUrl ($msg)" );
218 throw new MWException(
"Unable to store text to external storage" );
234 foreach ( $tryStores as $storeUrl ) {
235 list( $proto, $path ) = explode(
'://', $storeUrl, 2 );
236 $store = self::getStoreObject( $proto, [] );
237 if ( !$store->isReadOnly( $path ) ) {
252 return self::insertToDefault( $data, [
'wiki' => $wiki ] );
array $wgDefaultExternalStore
The place to put new revisions, false to put them in the local text table.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Constructor class for key/value blob data kept in external repositories.
static insertWithFallback(array $tryStores, $data, array $params=[])
Like insert() above, but does more of the work for us.
static fetchFromURL( $url, array $params=[])
Fetch data from given URL.
static insert( $url, $data, array $params=[])
Store a data item to an external store, identified by a partial URL The protocol part is used to iden...
static batchFetchFromURLs(array $urls)
Fetch data from multiple URLs with a minimum of round trips.
static insertToDefault( $data, array $params=[])
Like insert() above, but does more of the work for us.
static insertToForeignDefault( $data, $wiki)
static defaultStoresAreReadOnly()
static getStoreObject( $proto, array $params=[])
Get an external store object of the given type, with the given parameters.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
the array() calling protocol came about after MediaWiki 1.4rc1.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account incomplete not yet checked for validity & $retval