| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Extension\TemplateData; |
| 4 |
|
| 5 |
use MediaWiki\Message\Message; |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
class TemplateDataCompressedBlob extends TemplateDataBlob { |
| 16 |
|
| 17 |
|
| 18 |
private const MAX_LENGTH = 65535; |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
private string $jsonDB; |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
protected function __construct( string $json, string $lang ) { |
| 29 |
parent::__construct( $json, $lang ); |
| 30 |
$this->jsonDB = gzencode( $this->json ); |
| 31 |
|
| 32 |
$length = strlen( $this->jsonDB ); |
| 33 |
if ( $length > self::MAX_LENGTH ) { |
| 34 |
$this->status->fatal( |
| 35 |
'templatedata-invalid-length', |
| 36 |
Message::numParam( $length ), |
| 37 |
Message::numParam( self::MAX_LENGTH ) |
| 38 |
); |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
public function getJSONForDatabase(): string { |
| 46 |
return $this->jsonDB; |
| 47 |
} |
| 48 |
|
| 49 |
} |