pageBundle; } /** * @return int */ public function getRevisionID(): int { return $this->revId; } /** * @return Content|null */ public function getContent(): ?Content { return $this->content; } public function toJsonArray(): array { return [ 'revId' => $this->revId, 'pb' => $this->pageBundle, // After I544625136088164561b9169a63aed7450cce82f5 this can be: // 'c' => $this->content, 'content' => $this->content ? [ 'model' => $this->content->getModel(), 'data' => $this->content->serialize(), ] : null, ]; } public static function jsonClassHintFor( string $keyName ): ?string { if ( $keyName === 'pb' ) { return PageBundle::class; } return null; } public static function newFromJsonArray( array $json ): self { $revId = (int)$json['revId']; $pb = $json['pb']; if ( is_array( $pb ) ) { // Backward compatibility with old serialization format $pb = new PageBundle( $pb['html'], $pb['parsoid'] ?? null, $pb['mw'] ?? null, $pb['version'] ?? null, $pb['headers'] ?? null, $pb['contentmodel'] ?? null ); } $content = $json['c'] ?? $json['content'] ?? null; if ( is_array( $content ) ) { // Backward compatibility with old serialization format $contentHandler = MediaWikiServices::getInstance() ->getContentHandlerFactory() ->getContentHandler( $content['model'] ); $content = $contentHandler->unserializeContent( $content['data'] ); } return new self( $pb, $revId, $content ); } }