MediaWiki
1.34.0
|
Service for storing and loading Content objects. More...
Public Member Functions | |
__construct (ILoadBalancer $dbLoadBalancer, ExternalStoreAccess $extStoreAccess, WANObjectCache $cache, $dbDomain=false) | |
compressData (&$blob) | |
If $wgCompressRevisions is enabled, we will compress data. More... | |
decompressData ( $blob, array $blobFlags) | |
Re-converts revision text according to its flags. More... | |
expandBlob ( $raw, $flags, $cacheKey=null) | |
Expand a raw data blob according to the flags given. More... | |
getBlob ( $blobAddress, $queryFlags=0) | |
Retrieve a blob, given an address. More... | |
getBlobBatch ( $blobAddresses, $queryFlags=0) | |
A batched version of BlobStore::getBlob. More... | |
getCacheExpiry () | |
getCompressBlobs () | |
getLegacyEncoding () | |
getLegacyEncodingConversionLang () | |
getTextIdFromAddress ( $address) | |
Returns an ID corresponding to the old_id field in the text table, corresponding to the given $address. More... | |
getUseExternalStore () | |
isReadOnly () | |
Check if the blob metadata or backing blob data store is read-only. More... | |
setCacheExpiry ( $cacheExpiry) | |
setCompressBlobs ( $compressBlobs) | |
setLegacyEncoding ( $legacyEncoding) | |
Set the legacy encoding to assume for blobs that do not have the utf-8 flag set. More... | |
setUseExternalStore ( $useExternalStore) | |
storeBlob ( $data, $hints=[]) | |
Stores an arbitrary blob of data and returns an address that can be used with getBlob() to retrieve the same blob of data,. More... | |
Static Public Member Functions | |
static | makeAddressFromTextId ( $id) |
Returns an address referring to content stored in the text table row with the given ID. More... | |
static | splitBlobAddress ( $address) |
Splits a blob address into three parts: the schema, the ID, and parameters/flags. More... | |
Public Attributes | |
const | TEXT_CACHE_GROUP = 'revisiontext:10' |
Public Attributes inherited from IDBAccessObject | |
const | READ_LOCKING = self::READ_LATEST | 2 |
Constants for object loading bitfield flags (higher => higher QoS) More... | |
const | READ_NONE = -1 |
Public Attributes inherited from MediaWiki\Storage\BlobStore | |
const | DESIGNATION_HINT = 'designation' |
Hint key for use with storeBlob, indicating the general role the block takes in the application. More... | |
const | FORMAT_HINT = 'cont_format' |
Hint key for use with storeBlob, indicating the serialization format used to create the blob, as a MIME type. More... | |
const | MODEL_HINT = 'cont_model' |
Hint key for use with storeBlob, indicating the model of the content encoded in the given blob. More... | |
const | PAGE_HINT = 'page_id' |
Hint key for use with storeBlob, indicating the page the blob is associated with. More... | |
const | PARENT_HINT = 'rev_parent_id' |
Hint key for use with storeBlob, indicating the parent revision of the revision the blob is associated with. More... | |
const | REVISION_HINT = 'rev_id' |
Hint key for use with storeBlob, indicating the revision the blob is associated with. More... | |
const | ROLE_HINT = 'role_name' |
Hint key for use with storeBlob, indicating the slot the blob is associated with. More... | |
const | SHA1_HINT = 'cont_sha1' |
Hint key for use with storeBlob, providing the SHA1 hash of the blob as passed to the method. More... | |
Private Member Functions | |
fetchBlobs ( $blobAddresses, $queryFlags) | |
MCR migration note: this corresponds to Revision::fetchText. More... | |
getCacheKey ( $blobAddress) | |
Get a cache key for a given Blob address. More... | |
getCacheTTL () | |
Get the text cache TTL. More... | |
getDBConnection ( $index) | |
getDBLoadBalancer () | |
Private Attributes | |
WANObjectCache | $cache |
int | $cacheExpiry = 604800 |
bool | $compressBlobs = false |
string bool | $dbDomain |
DB domain ID of a wiki or false for the local one. More... | |
ILoadBalancer | $dbLoadBalancer |
ExternalStoreAccess | $extStoreAccess |
bool string | $legacyEncoding = false |
boolean | $useExternalStore = false |
Service for storing and loading Content objects.
Definition at line 51 of file SqlBlobStore.php.
MediaWiki\Storage\SqlBlobStore::__construct | ( | ILoadBalancer | $dbLoadBalancer, |
ExternalStoreAccess | $extStoreAccess, | ||
WANObjectCache | $cache, | ||
$dbDomain = false |
|||
) |
ILoadBalancer | $dbLoadBalancer | A load balancer for acquiring database connections |
ExternalStoreAccess | $extStoreAccess | Access layer for external storage |
WANObjectCache | $cache | A cache manager for caching blobs. This can be the local wiki's default instance even if $dbDomain refers to a different wiki, since makeGlobalKey() is used to construct a key that allows cached blobs from the same database to be re-used between wikis. For example, wiki A and wiki B will use the same cache keys for blobs fetched from wiki C, regardless of the wiki-specific default key space. |
bool | string | $dbDomain | The ID of the target wiki database. Use false for the local wiki. |
Definition at line 107 of file SqlBlobStore.php.
References MediaWiki\Storage\SqlBlobStore\$cache, MediaWiki\Storage\SqlBlobStore\$dbDomain, MediaWiki\Storage\SqlBlobStore\$dbLoadBalancer, and MediaWiki\Storage\SqlBlobStore\$extStoreAccess.
MediaWiki\Storage\SqlBlobStore::compressData | ( | & | $blob | ) |
If $wgCompressRevisions is enabled, we will compress data.
The input string is modified in place. Return value is the flags field: contains 'gzip' if the data is compressed, and 'utf-8' if we're saving in UTF-8 mode.
MCR migration note: this replaces Revision::compressRevisionText
mixed | &$blob | Reference to a text |
Definition at line 535 of file SqlBlobStore.php.
References $blob, wfDebug(), and wfLogWarning().
Referenced by MediaWiki\Storage\SqlBlobStore\storeBlob().
MediaWiki\Storage\SqlBlobStore::decompressData | ( | $blob, | |
array | $blobFlags | ||
) |
Re-converts revision text according to its flags.
MCR migration note: this replaces Revision::decompressRevisionText
string | $blob | Blob in compressed/encoded form. |
array | $blobFlags | Compression flags, such as 'gzip'. Note that not including 'utf-8' in $blobFlags will cause the data to be decoded according to the legacy encoding specified via setLegacyEncoding. |
Definition at line 575 of file SqlBlobStore.php.
References $blob, unserialize(), and wfWarn().
Referenced by MediaWiki\Storage\SqlBlobStore\expandBlob().
MediaWiki\Storage\SqlBlobStore::expandBlob | ( | $raw, | |
$flags, | |||
$cacheKey = null |
|||
) |
Expand a raw data blob according to the flags given.
MCR migration note: this replaces Revision::getRevisionText
string | $raw | The raw blob data, to be processed according to $flags. May be the blob itself, or the blob compressed, or just the address of the actual blob, depending on $flags. |
string | string[] | $flags | Blob flags, such as 'external' or 'gzip'. Note that not including 'utf-8' in $flags will cause the data to be decoded according to the legacy encoding specified via setLegacyEncoding. |
string | null | $cacheKey | A blob address for use in the cache key. If not given, caching is disabled. |
Definition at line 483 of file SqlBlobStore.php.
References $blob, MediaWiki\Storage\SqlBlobStore\decompressData(), MediaWiki\Storage\SqlBlobStore\getCacheKey(), MediaWiki\Storage\SqlBlobStore\getCacheTTL(), MediaWiki\Storage\SqlBlobStore\TEXT_CACHE_GROUP, and IExpiringStore\TTL_PROC_LONG.
Referenced by MediaWiki\Storage\SqlBlobStore\fetchBlobs().
|
private |
MCR migration note: this corresponds to Revision::fetchText.
string[] | $blobAddresses | |
int | $queryFlags |
BlobAccessException |
Definition at line 360 of file SqlBlobStore.php.
References $blob, MediaWiki\Storage\SqlBlobStore\expandBlob(), MediaWiki\Storage\SqlBlobStore\getDBConnection(), DBAccessObjectUtils\getDBOptions(), DBAccessObjectUtils\hasFlags(), and MediaWiki\Storage\SqlBlobStore\splitBlobAddress().
Referenced by MediaWiki\Storage\SqlBlobStore\getBlob(), and MediaWiki\Storage\SqlBlobStore\getBlobBatch().
MediaWiki\Storage\SqlBlobStore::getBlob | ( | $blobAddress, | |
$queryFlags = 0 |
|||
) |
Retrieve a blob, given an address.
Currently hardcoded to the 'text' table storage engine.
MCR migration note: this replaces Revision::loadText
string | $blobAddress | |
int | $queryFlags |
BlobAccessException |
Implements MediaWiki\Storage\BlobStore.
Definition at line 277 of file SqlBlobStore.php.
References $blob, MediaWiki\Storage\SqlBlobStore\fetchBlobs(), MediaWiki\Storage\SqlBlobStore\getCacheKey(), MediaWiki\Storage\SqlBlobStore\getCacheTTL(), MediaWiki\Storage\SqlBlobStore\TEXT_CACHE_GROUP, and IExpiringStore\TTL_PROC_LONG.
MediaWiki\Storage\SqlBlobStore::getBlobBatch | ( | $blobAddresses, | |
$queryFlags = 0 |
|||
) |
A batched version of BlobStore::getBlob.
string[] | $blobAddresses | An array of blob addresses. |
int | $queryFlags | See IDBAccessObject. |
BlobAccessException |
Implements MediaWiki\Storage\BlobStore.
Definition at line 313 of file SqlBlobStore.php.
References $blob, MediaWiki\Storage\SqlBlobStore\fetchBlobs(), MediaWiki\Storage\SqlBlobStore\getCacheKey(), MediaWiki\Storage\SqlBlobStore\getCacheTTL(), StatusValue\newGood(), MediaWiki\Storage\SqlBlobStore\TEXT_CACHE_GROUP, and IExpiringStore\TTL_PROC_LONG.
MediaWiki\Storage\SqlBlobStore::getCacheExpiry | ( | ) |
Definition at line 122 of file SqlBlobStore.php.
References MediaWiki\Storage\SqlBlobStore\$cacheExpiry.
|
private |
Get a cache key for a given Blob address.
The cache key is constructed in a way that allows cached blobs from the same database to be re-used between wikis. For example, wiki A and wiki B will use the same cache keys for blobs fetched from wiki C.
string | $blobAddress |
Definition at line 456 of file SqlBlobStore.php.
Referenced by MediaWiki\Storage\SqlBlobStore\expandBlob(), MediaWiki\Storage\SqlBlobStore\getBlob(), and MediaWiki\Storage\SqlBlobStore\getBlobBatch().
|
private |
Get the text cache TTL.
MCR migration note: this replaces Revision::getCacheTTL
Definition at line 633 of file SqlBlobStore.php.
References IExpiringStore\ATTR_EMULATION, and IExpiringStore\QOS_EMULATION_SQL.
Referenced by MediaWiki\Storage\SqlBlobStore\expandBlob(), MediaWiki\Storage\SqlBlobStore\getBlob(), and MediaWiki\Storage\SqlBlobStore\getBlobBatch().
MediaWiki\Storage\SqlBlobStore::getCompressBlobs | ( | ) |
Definition at line 138 of file SqlBlobStore.php.
References MediaWiki\Storage\SqlBlobStore\$compressBlobs.
|
private |
int | $index | A database index, like DB_MASTER or DB_REPLICA |
Definition at line 208 of file SqlBlobStore.php.
References MediaWiki\Storage\SqlBlobStore\getDBLoadBalancer().
Referenced by MediaWiki\Storage\SqlBlobStore\fetchBlobs(), and MediaWiki\Storage\SqlBlobStore\storeBlob().
|
private |
Definition at line 199 of file SqlBlobStore.php.
References MediaWiki\Storage\SqlBlobStore\$dbLoadBalancer.
Referenced by MediaWiki\Storage\SqlBlobStore\getDBConnection(), and MediaWiki\Storage\SqlBlobStore\isReadOnly().
MediaWiki\Storage\SqlBlobStore::getLegacyEncoding | ( | ) |
Definition at line 153 of file SqlBlobStore.php.
References MediaWiki\Storage\SqlBlobStore\$legacyEncoding.
MediaWiki\Storage\SqlBlobStore::getLegacyEncodingConversionLang | ( | ) |
Definition at line 161 of file SqlBlobStore.php.
References wfDeprecated().
MediaWiki\Storage\SqlBlobStore::getTextIdFromAddress | ( | $address | ) |
Returns an ID corresponding to the old_id field in the text table, corresponding to the given $address.
Currently, $address must start with 'tt:' followed by a decimal integer representing the old_id; if $address does not start with 'tt:', null is returned. However, the implementation may change to insert rows into the text table on the fly. This implies that this method cannot be static.
string | $address |
Definition at line 666 of file SqlBlobStore.php.
References MediaWiki\Storage\SqlBlobStore\splitBlobAddress().
MediaWiki\Storage\SqlBlobStore::getUseExternalStore | ( | ) |
Definition at line 183 of file SqlBlobStore.php.
References MediaWiki\Storage\SqlBlobStore\$useExternalStore.
MediaWiki\Storage\SqlBlobStore::isReadOnly | ( | ) |
Check if the blob metadata or backing blob data store is read-only.
Implements MediaWiki\Storage\BlobStore.
Definition at line 720 of file SqlBlobStore.php.
References MediaWiki\Storage\SqlBlobStore\getDBLoadBalancer().
|
static |
Returns an address referring to content stored in the text table row with the given ID.
The address schema for blobs stored in the text table is "tt:" followed by an integer that corresponds to a value of the old_id field.
int | $id |
Definition at line 694 of file SqlBlobStore.php.
Referenced by Revision\RevisionStore\emulateMainSlot_1_29(), MediaWiki\Storage\SqlBlobStore\storeBlob(), and Revision\RevisionStore\updateRevisionTextId().
MediaWiki\Storage\SqlBlobStore::setCacheExpiry | ( | $cacheExpiry | ) |
int | $cacheExpiry | time for which blobs can be cached, in seconds |
Definition at line 129 of file SqlBlobStore.php.
References MediaWiki\Storage\SqlBlobStore\$cacheExpiry.
MediaWiki\Storage\SqlBlobStore::setCompressBlobs | ( | $compressBlobs | ) |
bool | $compressBlobs | whether blobs should be compressed for storage |
Definition at line 145 of file SqlBlobStore.php.
References MediaWiki\Storage\SqlBlobStore\$compressBlobs.
MediaWiki\Storage\SqlBlobStore::setLegacyEncoding | ( | $legacyEncoding | ) |
Set the legacy encoding to assume for blobs that do not have the utf-8 flag set.
string | $legacyEncoding | The legacy encoding to assume for blobs that are not marked as utf8. |
Definition at line 174 of file SqlBlobStore.php.
References MediaWiki\Storage\SqlBlobStore\$legacyEncoding.
MediaWiki\Storage\SqlBlobStore::setUseExternalStore | ( | $useExternalStore | ) |
bool | $useExternalStore | Whether to use the ExternalStore mechanism for storing blobs. |
Definition at line 190 of file SqlBlobStore.php.
References MediaWiki\Storage\SqlBlobStore\$useExternalStore.
|
static |
Splits a blob address into three parts: the schema, the ID, and parameters/flags.
string | $address |
InvalidArgumentException |
Definition at line 708 of file SqlBlobStore.php.
References wfCgiToArray().
Referenced by MediaWiki\Storage\SqlBlobStore\fetchBlobs(), and MediaWiki\Storage\SqlBlobStore\getTextIdFromAddress().
MediaWiki\Storage\SqlBlobStore::storeBlob | ( | $data, | |
$hints = [] |
|||
) |
Stores an arbitrary blob of data and returns an address that can be used with getBlob() to retrieve the same blob of data,.
string | $data | |
array | $hints | An array of hints. |
BlobAccessException |
Implements MediaWiki\Storage\BlobStore.
Definition at line 223 of file SqlBlobStore.php.
References MediaWiki\Storage\SqlBlobStore\compressData(), DB_MASTER, MediaWiki\Storage\SqlBlobStore\getDBConnection(), and MediaWiki\Storage\SqlBlobStore\makeAddressFromTextId().
|
private |
Definition at line 69 of file SqlBlobStore.php.
Referenced by MediaWiki\Storage\SqlBlobStore\__construct().
|
private |
Definition at line 79 of file SqlBlobStore.php.
Referenced by MediaWiki\Storage\SqlBlobStore\getCacheExpiry(), and MediaWiki\Storage\SqlBlobStore\setCacheExpiry().
|
private |
Definition at line 84 of file SqlBlobStore.php.
Referenced by MediaWiki\Storage\SqlBlobStore\getCompressBlobs(), and MediaWiki\Storage\SqlBlobStore\setCompressBlobs().
|
private |
DB domain ID of a wiki or false for the local one.
Definition at line 74 of file SqlBlobStore.php.
Referenced by MediaWiki\Storage\SqlBlobStore\__construct().
|
private |
Definition at line 59 of file SqlBlobStore.php.
Referenced by MediaWiki\Storage\SqlBlobStore\__construct(), and MediaWiki\Storage\SqlBlobStore\getDBLoadBalancer().
|
private |
Definition at line 64 of file SqlBlobStore.php.
Referenced by MediaWiki\Storage\SqlBlobStore\__construct().
|
private |
Definition at line 89 of file SqlBlobStore.php.
Referenced by MediaWiki\Storage\SqlBlobStore\getLegacyEncoding(), and MediaWiki\Storage\SqlBlobStore\setLegacyEncoding().
|
private |
Definition at line 94 of file SqlBlobStore.php.
Referenced by MediaWiki\Storage\SqlBlobStore\getUseExternalStore(), and MediaWiki\Storage\SqlBlobStore\setUseExternalStore().
const MediaWiki\Storage\SqlBlobStore::TEXT_CACHE_GROUP = 'revisiontext:10' |
Definition at line 54 of file SqlBlobStore.php.
Referenced by MediaWiki\Storage\SqlBlobStore\expandBlob(), MediaWiki\Storage\SqlBlobStore\getBlob(), and MediaWiki\Storage\SqlBlobStore\getBlobBatch().