33use InvalidArgumentException;
125 Assert::parameterType(
'integer',
$cacheExpiry,
'$cacheExpiry' );
169 $this->legacyEncodingConversionLang = $language;
202 return $lb->getConnection( $index, [], $this->wikiId );
219 # Write to external storage if required
220 if ( $this->useExternalStore ) {
229 $flags .=
'external';
238 $old_id = $dbw->nextSequenceValue(
'text_old_id_seq' );
244 'old_flags' => $flags,
249 $textId = $dbw->insertId();
269 public function getBlob( $blobAddress, $queryFlags = 0 ) {
270 Assert::parameterType(
'string', $blobAddress,
'$blobAddress' );
276 function ( $unused, &$ttl, &$setOpts ) use ( $blobAddress, $queryFlags ) {
278 return $this->
fetchBlob( $blobAddress, $queryFlags );
283 if (
$blob ===
false ) {
299 private function fetchBlob( $blobAddress, $queryFlags ) {
303 if ( $schema ===
'tt' ) {
310 if ( !$textId || $id !== (
string)$textId ) {
317 $queryFlags |= DBAccessObjectUtils::hasFlags( $queryFlags, self::READ_LATEST )
321 list( $index,
$options, $fallbackIndex, $fallbackOptions ) =
322 DBAccessObjectUtils::getDBOptions( $queryFlags );
327 [
'old_text',
'old_flags' ],
328 [
'old_id' => $textId ],
335 if ( !$row && $fallbackIndex !==
null ) {
338 [
'old_text',
'old_flags' ],
339 [
'old_id' => $textId ],
346 wfWarn( __METHOD__ .
": No text row with ID $textId." );
350 $blob = $this->
expandBlob( $row->old_text, $row->old_flags, $blobAddress );
352 if (
$blob ===
false ) {
353 wfLogWarning( __METHOD__ .
": Bad data in text row $textId." );
371 return $this->
cache->makeGlobalKey(
374 $this->dbLoadBalancer->resolveDomainID( $this->wikiId ),
398 public function expandBlob( $raw, $flags, $cacheKey =
null ) {
400 $flags = explode(
',', $flags );
404 if (
in_array(
'external', $flags ) ) {
406 $parts = explode(
'://', $url, 2 );
407 if ( count( $parts ) == 1 || $parts[1] ==
'' ) {
413 return $this->
cache->getWithSetCallback(
416 function () use ( $url, $flags ) {
455 $blobFlags[] =
'utf-8';
457 if ( $this->compressBlobs ) {
461 if ( $deflated ===
false ) {
465 $blobFlags[] =
'gzip';
468 wfDebug( __METHOD__ .
" -- no zlib support, not compressing\n" );
471 return implode(
',', $blobFlags );
491 Assert::parameterType(
'string',
$blob,
'$blob' );
493 if (
in_array(
'error', $blobFlags ) ) {
498 if (
in_array(
'gzip', $blobFlags ) ) {
499 # Deal with optional compression of archived pages.
500 # This can be done periodically via maintenance/compressOld.php, and
501 # as pages are saved if $wgCompressRevisions is set.
504 if (
$blob ===
false ) {
505 wfWarn( __METHOD__ .
': gzinflate() failed' );
510 if (
in_array(
'object', $blobFlags ) ) {
511 # Generic compressed storage
517 $blob = $obj->getText();
521 if (
$blob !==
false && $this->legacyEncoding && $this->legacyEncodingConversionLang
524 # Old revisions kept around in a legacy encoding?
525 # Upconvert on demand.
526 # ("utf8" checked for compatibility with some broken
527 # conversion scripts 2008-12-30)
528 $blob = $this->legacyEncodingConversionLang->iconv( $this->legacyEncoding,
'UTF-8',
$blob );
542 if ( $this->
cache->getQoS( WANObjectCache::ATTR_EMULATION )
543 <= WANObjectCache::QOS_EMULATION_SQL
546 $ttl = WANObjectCache::TTL_UNCACHEABLE;
548 $ttl = $this->cacheExpiry ?: WANObjectCache::TTL_UNCACHEABLE;
577 if ( $schema !==
'tt' ) {
583 if ( !$textId || $id !== (
string)$textId ) {
584 throw new InvalidArgumentException(
"Malformed text_id: $id" );
617 if ( !
preg_match(
'/^(\w+):(\w+)(\?(.*))?$/', $address, $m ) ) {
618 throw new InvalidArgumentException(
"Bad blob address: $address" );
625 return [ $schema, $id, $parameters ];
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
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
wfCgiToArray( $query)
This is the logical opposite of wfArrayToCgi(): it accepts a query string as its argument and returns...
Helper class for DAO classes.
Constructor class for key/value blob data kept in external repositories.
static fetchFromURL( $url, array $params=[])
Fetch data from given URL.
static insertToDefault( $data, array $params=[])
Like insert() above, but does more of the work for us.
static defaultStoresAreReadOnly()
Internationalisation code.
Multi-datacenter aware caching interface.
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 & $options
processing should stop and the error should be shown to the user * false
returning false will NOT prevent logging $e
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
Interface for database access objects.
Generic interface for lightweight expiring object stores.
you have access to all of the normal MediaWiki so you can get a DB use the cache
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))