Go to the documentation of this file.
46 list( $cluster, $id, $itemID ) = $this->
parseURL( $url );
49 if ( $itemID !==
false &&
$ret !==
false ) {
50 return $ret->getItem( $itemID );
66 $batched = $inverseUrlMap = [];
67 foreach ( $urls
as $url ) {
68 list( $cluster, $id, $itemID ) = $this->
parseURL( $url );
69 $batched[$cluster][$id][] = $itemID;
72 $inverseUrlMap[$cluster][$id][$itemID] = $url;
75 foreach ( $batched
as $cluster => $batchByCluster ) {
79 foreach ( $batchByCluster[$id]
as $itemID ) {
80 $url = $inverseUrlMap[$cluster][$id][$itemID];
81 if ( $itemID ===
false ) {
93 public function store( $location, $data ) {
95 $dbw->insert( $this->
getTable( $dbw ),
96 [
'blob_text' => $data ],
98 $id = $dbw->insertId();
100 throw new MWException( __METHOD__ .
': no insert ID' );
103 return "DB://$location/$id";
125 $wiki = isset( $this->params[
'wiki'] ) ? $this->params[
'wiki'] :
false;
129 wfDebug(
"read only external store\n" );
130 $lb->allowLagged(
true );
132 wfDebug(
"writable external store\n" );
135 $db = $lb->getConnectionRef(
DB_REPLICA, [], $wiki );
148 $wiki = isset( $this->params[
'wiki'] ) ? $this->params[
'wiki'] :
false;
151 $db = $lb->getMaintenanceConnectionRef(
DB_MASTER, [], $wiki );
164 $table = $db->getLBInfo(
'blobs table' );
165 if ( is_null( $table ) ) {
188 static $externalBlobCache = [];
190 $cacheID = ( $itemID ===
false ) ?
"$cluster/$id" :
"$cluster/$id/";
191 if ( isset( $externalBlobCache[$cacheID] ) ) {
193 "ExternalStoreDB::fetchBlob cache hit on $cacheID" );
195 return $externalBlobCache[$cacheID];
199 "ExternalStoreDB::fetchBlob cache miss on $cacheID" );
203 'blob_text', [
'blob_id' => $id ], __METHOD__ );
204 if (
$ret ===
false ) {
206 "ExternalStoreDB::fetchBlob master fallback on $cacheID" );
210 'blob_text', [
'blob_id' => $id ], __METHOD__ );
211 if (
$ret ===
false ) {
213 "ExternalStoreDB::fetchBlob master failed to find $cacheID" );
216 if ( $itemID !==
false &&
$ret !==
false ) {
221 $externalBlobCache = [ $cacheID =>
$ret ];
237 [
'blob_id',
'blob_text' ], [
'blob_id' => array_keys( $ids ) ], __METHOD__ );
239 if (
$res !==
false ) {
244 " master fallback on '$cluster' for: " .
245 implode(
',', array_keys( $ids ) ) );
249 [
'blob_id',
'blob_text' ],
250 [
'blob_id' => array_keys( $ids ) ],
252 if (
$res ===
false ) {
253 wfDebugLog( __CLASS__, __METHOD__ .
" master failed on '$cluster'" );
260 " master on '$cluster' failed locating items: " .
261 implode(
',', array_keys( $ids ) ) );
274 foreach (
$res as $row ) {
276 $itemIDs = $ids[$id];
278 if (
count( $itemIDs ) === 1 && reset( $itemIDs ) ===
false ) {
280 $ret[$id] = $row->blob_text;
293 $path = explode(
'/', $url );
batchFetchBlobs( $cluster, array $ids)
Fetch multiple blob items out of the database.
Accessable external objects in a particular storage medium.
processing should stop and the error should be shown to the user * false
getSlave( $cluster)
Get a replica DB connection for the specified cluster.
DB accessable external objects.
store( $location, $data)
Insert a data item into a given location.
batchFetchFromURLs(array $urls)
Fetch data from given external store URLs.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
unserialize( $serialized)
array $wgDefaultExternalStore
The place to put new revisions, false to put them in the local text table.
fetchBlob( $cluster, $id, $itemID)
Fetch a blob item out of the database; a cache of the last-loaded blob will be kept so that multiple ...
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Helper class to handle automatically marking connections as reusable (via RAII pattern) as well handl...
getLoadBalancer( $cluster)
Get a LoadBalancer for the specified cluster.
when a variable name is used in a it is silently declared as a new masking the global
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
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
getTable( $db)
Get the 'blobs' table name for this database.
fetchFromURL( $url)
The provided URL is in the form of DB://cluster/id or DB://cluster/id/itemid for concatened storage.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
wfGetLBFactory()
Get the load balancer factory object.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
mergeBatchResult(array &$ret, array &$ids, $res)
Helper function for self::batchFetchBlobs for merging master/replica DB results.
getMaster( $cluster)
Get a master database connection for the specified cluster.
the array() calling protocol came about after MediaWiki 1.4rc1.