X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FStorage%2FSqlBlobStore.php;h=72de2c961ab6b5c0b5bd12fe3059ec96c1acfda7;hp=031cb587ed617082e1f0107ab08a789e3ff3556c;hb=478a58f63101f2b47d18a618296b5e7970fa3f24;hpb=07a791ffd1d80c6a8f2ca4dfdbc3f2002ac869fe diff --git a/includes/Storage/SqlBlobStore.php b/includes/Storage/SqlBlobStore.php index 031cb587ed..72de2c961a 100644 --- a/includes/Storage/SqlBlobStore.php +++ b/includes/Storage/SqlBlobStore.php @@ -244,7 +244,7 @@ class SqlBlobStore implements IDBAccessObject, BlobStore { $textId = $dbw->insertId(); - return 'tt:' . $textId; + return self::makeAddressFromTextId( $textId ); } catch ( MWException $e ) { throw new BlobAccessException( $e->getMessage(), 0, $e ); } @@ -292,14 +292,13 @@ class SqlBlobStore implements IDBAccessObject, BlobStore { * @param string $blobAddress * @param int $queryFlags * - * @throw BlobAccessException + * @throws BlobAccessException * @return string|false */ private function fetchBlob( $blobAddress, $queryFlags ) { list( $schema, $id, ) = self::splitBlobAddress( $blobAddress ); //TODO: MCR: also support 'ex' schema with ExternalStore URLs, plus flags encoded in the URL! - //TODO: MCR: also support 'ar' schema for content blobs in old style archive rows! if ( $schema === 'tt' ) { $textId = intval( $id ); } else { @@ -543,11 +542,12 @@ class SqlBlobStore implements IDBAccessObject, BlobStore { * 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. * * @note This method exists for use with the text table based storage schema. * It should not be assumed that is will function with all future kinds of content addresses. * - * @deprecated since 1.31, so not assume that all blob addresses refer to a row in the text + * @deprecated since 1.31, so don't assume that all blob addresses refer to a row in the text * table. This method should become private once the relevant refactoring in WikiPage is * complete. * @@ -571,6 +571,22 @@ class SqlBlobStore implements IDBAccessObject, BlobStore { return $textId; } + /** + * 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. + * + * @deprecated since 1.31. This method should become private once the relevant refactoring + * in WikiPage is complete. + * + * @param int $id + * + * @return string + */ + public static function makeAddressFromTextId( $id ) { + return 'tt:' . $id; + } + /** * Splits a blob address into three parts: the schema, the ID, and parameters/flags. * @@ -591,4 +607,11 @@ class SqlBlobStore implements IDBAccessObject, BlobStore { return [ $schema, $id, $parameters ]; } + public function isReadOnly() { + if ( $this->useExternalStore && ExternalStore::defaultStoresAreReadOnly() ) { + return true; + } + + return ( $this->getDBLoadBalancer()->getReadOnlyReason() !== false ); + } }