48 list( $cluster, $id, $itemID ) = $this->
parseURL( $url );
51 if ( $itemID !==
false &&
$ret !==
false ) {
52 return $ret->getItem( $itemID );
68 $batched = $inverseUrlMap = [];
69 foreach (
$urls as $url ) {
70 list( $cluster, $id, $itemID ) = $this->
parseURL( $url );
71 $batched[$cluster][$id][] =
$itemID;
74 $inverseUrlMap[$cluster][$id][
$itemID] = $url;
77 foreach ( $batched as $cluster => $batchByCluster ) {
81 foreach ( $batchByCluster[$id] as $itemID ) {
82 $url = $inverseUrlMap[$cluster][$id][
$itemID];
83 if ( $itemID ===
false ) {
97 $dbw->insert( $this->
getTable( $dbw ),
98 [
'blob_text' =>
$data ],
100 $id = $dbw->insertId();
102 throw new MWException( __METHOD__ .
': no insert ID' );
105 return "DB://$location/$id";
110 $domainId = $this->
getDomainId( $lb->getServerInfo( $lb->getWriterIndex() ) );
111 return ( $lb->getReadOnlyReason( $domainId ) !==
false );
121 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
122 return $lbFactory->getExternalLB( $cluster );
135 $domainId = $this->
getDomainId( $lb->getServerInfo( $lb->getWriterIndex() ) );
138 wfDebug(
"read only external store\n" );
139 $lb->allowLagged(
true );
141 wfDebug(
"writable external store\n" );
144 $db = $lb->getConnectionRef(
DB_REPLICA, [], $domainId );
158 $domainId = $this->
getDomainId( $lb->getServerInfo( $lb->getWriterIndex() ) );
160 $db = $lb->getMaintenanceConnectionRef(
DB_MASTER, [], $domainId );
171 if (
isset( $this->params[
'wiki'] ) && $this->params[
'wiki'] !==
false ) {
172 return $this->params[
'wiki'];
175 if (
isset( $server[
'dbname'] ) ) {
183 $server[
'schema'] ??
null,
184 $server[
'tablePrefix'] ??
''
187 return $domain->getId();
200 $table = $db->getLBInfo(
'blobs table' );
224 static $externalBlobCache = [];
226 $cacheID = ( $itemID ===
false ) ?
"$cluster/$id" :
"$cluster/$id/";
228 $wiki = $this->params[
'wiki'] ??
false;
229 $cacheID = ( $wiki ===
false ) ? $cacheID :
"$cacheID@$wiki";
231 if (
isset( $externalBlobCache[$cacheID] ) ) {
233 "ExternalStoreDB::fetchBlob cache hit on $cacheID" );
235 return $externalBlobCache[
$cacheID];
239 "ExternalStoreDB::fetchBlob cache miss on $cacheID" );
243 'blob_text', [
'blob_id' => $id ], __METHOD__ );
244 if (
$ret ===
false ) {
246 "ExternalStoreDB::fetchBlob master fallback on $cacheID" );
250 'blob_text', [
'blob_id' => $id ], __METHOD__ );
251 if (
$ret ===
false ) {
253 "ExternalStoreDB::fetchBlob master failed to find $cacheID" );
256 if ( $itemID !==
false &&
$ret !==
false ) {
261 $externalBlobCache = [ $cacheID =>
$ret ];
277 [
'blob_id',
'blob_text' ], [
'blob_id' =>
array_keys( $ids ) ], __METHOD__ );
279 if (
$res !==
false ) {
284 " master fallback on '$cluster' for: " .
289 [
'blob_id',
'blob_text' ],
292 if (
$res ===
false ) {
293 wfDebugLog( __CLASS__, __METHOD__ .
" master failed on '$cluster'" );
300 " master on '$cluster' failed locating items: " .
314 foreach (
$res as $row ) {
316 $itemIDs = $ids[$id];
318 if ( count( $itemIDs ) === 1 && reset( $itemIDs ) ===
false ) {
320 $ret[$id] = $row->blob_text;
333 $path = explode(
'/', $url );
unserialize( $serialized)
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
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.
DB accessible external objects.
getSlave( $cluster)
Get a replica DB connection for the specified cluster.
batchFetchBlobs( $cluster, array $ids)
Fetch multiple blob items out of the database.
mergeBatchResult(array &$ret, array &$ids, $res)
Helper function for self::batchFetchBlobs for merging master/replica DB results.
getDomainId(array $server)
getMaster( $cluster)
Get a master database connection for the specified cluster.
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 ...
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.
store( $location, $data)
Insert a data item into a given location.
batchFetchFromURLs(array $urls)
Fetch data from given external store URLs.
isReadOnly( $location)
Check if a given location is read-only.
getLoadBalancer( $cluster)
Get a LoadBalancer for the specified cluster.
Accessable external objects in a particular storage medium.
Class to handle database/prefix specification for IDatabase domains.
Helper class to handle automatically marking connections as reusable (via RAII pattern) as well handl...
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
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
processing should stop and the error should be shown to the user * false
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))