Page MenuHomePhabricator

Make the Message classes JSON serializable
Closed, DeclinedPublic

Description

As a followup to the fallout of T323236: PHP Warning: Class RawMessage has no unserializer, and eventual fixing of T325703: Switch Echo serialization format from PHP to JSON; the Message classes (and heirarchy) should be migrated away from using PHP serialization, in further support of T161647: RFC: Deprecate using php serialization inside MediaWiki.

Event Timeline

MessageValue and related classes support JSON serialization since rMWc7f52f0ddb45: Make MessageValue implement JsonDeserializable. I would suggest using them instead of Message in any code that needs to serialize messages (they can be converted to each other easily enough), and not adding new features to the Message class.

Per above, I think this shouldn't be done. You can instead JSON-serialize the MessageValue class, and you can convert a Message to MessageValue using MessageValue::newFromSpecifier( $message ) (new in MW 1.43).