diff --git a/includes/Storage/SqlBlobStore.php b/includes/Storage/SqlBlobStore.php index d865cfda32..0b14b4eb39 100644 --- a/includes/Storage/SqlBlobStore.php +++ b/includes/Storage/SqlBlobStore.php @@ -35,6 +35,7 @@ use InvalidArgumentException; use MWException; use StatusValue; use WANObjectCache; +use Wikibase\Repo\WikibaseRepo; use Wikimedia\Assert\Assert; use Wikimedia\AtEase\AtEase; use Wikimedia\Rdbms\IDatabase; @@ -224,6 +225,13 @@ class SqlBlobStore implements IDBAccessObject, BlobStore { try { $flags = $this->compressData( $data ); + if ( $hints[BlobStore::MODEL_HINT] === "wikibase-item" ) { + $mongoEntityCollection = WikibaseRepo::getDefaultInstance()->getMongoEntityCollection(); + $insertOneResult = $mongoEntityCollection->insertOne( + json_decode($data, true) + ); + return "mongo:" . $insertOneResult->getInsertedId(); + } # Write to external storage if required if ( $this->useExternalStore ) { // Store and get the URL @@ -374,6 +382,8 @@ class SqlBlobStore implements IDBAccessObject, BlobStore { } $textIdToBlobAddress[$textId] = $blobAddress; + } elseif ( $schema === 'mongo' ) { + $textIdToBlobAddress[$id] = $blobAddress; } else { $errors[$blobAddress] = "Unknown blob address schema: $schema." . ' Use findBadBlobs.php to remedy.'; @@ -386,6 +396,11 @@ class SqlBlobStore implements IDBAccessObject, BlobStore { if ( !$textIds ) { return [ $result, $errors ]; } + + if ( $schema === 'mongo' ) { + + } + // Callers doing updates will pass in READ_LATEST as usual. Since the text/blob tables // do not normally get rows changed around, set READ_LATEST_IMMUTABLE in those cases. $queryFlags |= DBAccessObjectUtils::hasFlags( $queryFlags, self::READ_LATEST )