53 if ( !$this->repo->isSplitMetadataEnabled()
54 || !$file->getHandler()
55 || !$file->getHandler()->useSplitMetadata()
59 $threshold = $this->repo->getSplitMetadataThreshold();
60 if ( !$threshold || strlen( $s ) <= $threshold ) {
63 $blobStore = $this->repo->getBlobStore();
71 foreach ( $envelope[
'data'] as $name => $value ) {
73 if ( strlen( $encoded ) > $threshold ) {
74 $blobAddresses[$name] = $blobStore->storeBlob(
76 [ BlobStore::IMAGE_HINT => $file->getName() ]
81 $envelope[
'data'] = array_diff_key( $envelope[
'data'], $blobAddresses );
82 $envelope[
'blobs'] = $blobAddresses;
85 return [ $s, $blobAddresses ];
95 $s = json_encode( $data,
96 JSON_INVALID_UTF8_IGNORE |
97 JSON_UNESCAPED_SLASHES |
98 JSON_UNESCAPED_UNICODE );
100 throw new InvalidArgumentException( __METHOD__ .
': metadata is not JSON-serializable ' );
112 $blobStore = $this->repo->getBlobStore();
114 LoggerFactory::getInstance(
'LocalFile' )->warning(
115 "Unable to load metadata: repo has no blob store" );
118 $status = $blobStore->getBlobBatch( $addresses );
119 if ( !$status->isGood() ) {
120 $msg = Status::wrap( $status )->getWikiText(
121 false,
false,
'en' );
122 LoggerFactory::getInstance(
'LocalFile' )->warning(
123 "Error loading metadata from BlobStore: $msg" );
125 foreach ( $addresses as $itemName => $address ) {
126 $json = $status->getValue()[$address] ??
null;
127 if ( $json !==
null ) {
128 $value = $this->jsonDecode( $json );
129 $result[$itemName] = $value;
149 return @json_decode( $s,
true, 512, JSON_INVALID_UTF8_IGNORE );
Local repository that stores files in the local filesystem and registers them in the wiki's own datab...