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 ];
97 $s = json_encode( $data,
98 JSON_INVALID_UTF8_IGNORE |
99 JSON_UNESCAPED_SLASHES |
100 JSON_UNESCAPED_UNICODE );
101 if ( $s ===
false ) {
102 throw new MWException( __METHOD__ .
': metadata is not JSON-serializable ' );
114 $blobStore = $this->repo->getBlobStore();
116 LoggerFactory::getInstance(
'LocalFile' )->warning(
117 "Unable to load metadata: repo has no blob store" );
120 $status = $blobStore->getBlobBatch( $addresses );
121 if ( !$status->isGood() ) {
122 $msg = Status::wrap( $status )->getWikiText(
123 false,
false,
'en' );
124 LoggerFactory::getInstance(
'LocalFile' )->warning(
125 "Error loading metadata from BlobStore: $msg" );
127 foreach ( $addresses as $itemName => $address ) {
128 $json = $status->getValue()[$address] ??
null;
129 if ( $json !==
null ) {
130 $value = $this->jsonDecode( $json );
131 $result[$itemName] = $value;
151 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...
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.