MediaWiki master
|
Service for storing and loading Content objects representing revision data blobs. More...
Inherits MediaWiki\Storage\BlobStore.
Public Member Functions | |
__construct (ILoadBalancer $dbLoadBalancer, ExternalStoreAccess $extStoreAccess, WANObjectCache $cache, $dbDomain=false) | |
compressData (&$blob) | |
If $wgCompressRevisions is enabled, we will compress data. | |
decompressData (string $blob, array $blobFlags) | |
Re-converts revision text according to its flags. | |
expandBlob ( $raw, $flags, $blobAddress=null) | |
Expand a raw data blob according to the flags given. | |
getBlob ( $blobAddress, $queryFlags=0) | |
Retrieve a blob, given an address. | |
getBlobBatch ( $blobAddresses, $queryFlags=0) | |
A batched version of BlobStore::getBlob. | |
getCacheExpiry () | |
getCompressBlobs () | |
getLegacyEncoding () | |
getTextIdFromAddress ( $address) | |
Returns an ID corresponding to the old_id field in the text table, corresponding to the given $address. | |
getUseExternalStore () | |
isReadOnly () | |
Check if the blob metadata or backing blob data store is read-only. | |
setCacheExpiry (int $cacheExpiry) | |
setCompressBlobs ( $compressBlobs) | |
setLegacyEncoding (string $legacyEncoding) | |
Set the legacy encoding to assume for blobs that do not have the utf-8 flag set. | |
setUseExternalStore (bool $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,. | |
Static Public Member Functions | |
static | explodeFlags (string $flagsString) |
Split a comma-separated old_flags value into its constituent parts. | |
static | makeAddressFromTextId ( $id) |
Returns an address referring to content stored in the text table row with the given ID. | |
static | splitBlobAddress ( $address) |
Splits a blob address into three parts: the schema, the ID, and parameters/flags. | |
Public Attributes | |
const | DEFAULT_TTL = 7 * 24 * 3600 |
const | TEXT_CACHE_GROUP = 'revisiontext:10' |
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. | |
const | FORMAT_HINT = 'cont_format' |
Hint key for use with storeBlob, indicating the serialization format used to create the blob, as a MIME type. | |
const | IMAGE_HINT = 'img_name' |
Hint key for an image name. | |
const | MODEL_HINT = 'cont_model' |
Hint key for use with storeBlob, indicating the model of the content encoded in the given blob. | |
const | PAGE_HINT = 'page_id' |
Hint key for use with storeBlob, indicating the page the blob is associated with. | |
const | PARENT_HINT = 'rev_parent_id' |
Hint key for use with storeBlob, indicating the parent revision of the revision the blob is associated with. | |
const | REVISION_HINT = 'rev_id' |
Hint key for use with storeBlob, indicating the revision the blob is associated with. | |
const | ROLE_HINT = 'role_name' |
Hint key for use with storeBlob, indicating the slot the blob is associated with. | |
const | SHA1_HINT = 'cont_sha1' |
Hint key for use with storeBlob, providing the SHA1 hash of the blob as passed to the method. | |
Service for storing and loading Content objects representing revision data blobs.
Definition at line 50 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 109 of file SqlBlobStore.php.
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 replaced Revision::compressRevisionText
string | &$blob |
Definition at line 602 of file SqlBlobStore.php.
References wfDebug(), and wfLogWarning().
Referenced by MediaWiki\Storage\SqlBlobStore\storeBlob().
MediaWiki\Storage\SqlBlobStore::decompressData | ( | string | $blob, |
array | $blobFlags ) |
Re-converts revision text according to its flags.
MCR migration note: this replaced 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 642 of file SqlBlobStore.php.
References HistoryBlobUtils\unserialize(), and wfWarn().
Referenced by MediaWiki\Storage\SqlBlobStore\expandBlob().
MediaWiki\Storage\SqlBlobStore::expandBlob | ( | $raw, | |
$flags, | |||
$blobAddress = null ) |
Expand a raw data blob according to the flags given.
MCR migration note: this replaced 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 | $blobAddress | A blob address for use in the cache key. If not given, caching is disabled. |
BlobAccessException |
Definition at line 545 of file SqlBlobStore.php.
References $url, MediaWiki\Storage\SqlBlobStore\decompressData(), MediaWiki\Storage\SqlBlobStore\explodeFlags(), and getCacheKey().
|
static |
Split a comma-separated old_flags value into its constituent parts.
string | $flagsString |
Definition at line 769 of file SqlBlobStore.php.
Referenced by MediaWiki\Storage\SqlBlobStore\expandBlob().
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 replaced Revision::loadText
string | $blobAddress | |
int | $queryFlags |
BlobAccessException |
Implements MediaWiki\Storage\BlobStore.
Definition at line 255 of file SqlBlobStore.php.
References getCacheKey().
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 298 of file SqlBlobStore.php.
MediaWiki\Storage\SqlBlobStore::getCacheExpiry | ( | ) |
Definition at line 124 of file SqlBlobStore.php.
MediaWiki\Storage\SqlBlobStore::getCompressBlobs | ( | ) |
Definition at line 138 of file SqlBlobStore.php.
MediaWiki\Storage\SqlBlobStore::getLegacyEncoding | ( | ) |
Definition at line 153 of file SqlBlobStore.php.
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 730 of file SqlBlobStore.php.
References MediaWiki\Storage\SqlBlobStore\splitBlobAddress().
MediaWiki\Storage\SqlBlobStore::getUseExternalStore | ( | ) |
Definition at line 172 of file SqlBlobStore.php.
MediaWiki\Storage\SqlBlobStore::isReadOnly | ( | ) |
Check if the blob metadata or backing blob data store is read-only.
Implements MediaWiki\Storage\BlobStore.
Definition at line 794 of file SqlBlobStore.php.
|
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 759 of file SqlBlobStore.php.
Referenced by MediaWiki\Storage\SqlBlobStore\storeBlob().
MediaWiki\Storage\SqlBlobStore::setCacheExpiry | ( | int | $cacheExpiry | ) |
int | $cacheExpiry | Time for which blobs can be cached, in seconds |
Definition at line 131 of file SqlBlobStore.php.
MediaWiki\Storage\SqlBlobStore::setCompressBlobs | ( | $compressBlobs | ) |
bool | $compressBlobs | Whether blobs should be compressed for storage |
Definition at line 145 of file SqlBlobStore.php.
MediaWiki\Storage\SqlBlobStore::setLegacyEncoding | ( | string | $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 165 of file SqlBlobStore.php.
MediaWiki\Storage\SqlBlobStore::setUseExternalStore | ( | bool | $useExternalStore | ) |
bool | $useExternalStore | Whether to use the ExternalStore mechanism for storing blobs. |
Definition at line 179 of file SqlBlobStore.php.
|
static |
Splits a blob address into three parts: the schema, the ID, and parameters/flags.
string | $address |
Definition at line 782 of file SqlBlobStore.php.
References wfCgiToArray().
Referenced by 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 210 of file SqlBlobStore.php.
References MediaWiki\Storage\SqlBlobStore\compressData(), DB_PRIMARY, and MediaWiki\Storage\SqlBlobStore\makeAddressFromTextId().
const MediaWiki\Storage\SqlBlobStore::DEFAULT_TTL = 7 * 24 * 3600 |
Definition at line 56 of file SqlBlobStore.php.
const MediaWiki\Storage\SqlBlobStore::TEXT_CACHE_GROUP = 'revisiontext:10' |
Definition at line 53 of file SqlBlobStore.php.