Page MenuHomePhabricator

JsonCodec should be a standalone library
Closed, ResolvedPublic

Description

Parsoid can't implement deserializers without a cyclic dependency on core, as the necessary JsonUnserializable interface is internal to core. It would also like to be able to use a consistent JSON codec to implement output in parser tests, in standalone mode, etc.

Other library code (see https://www.mediawiki.org/wiki/Parsoid/OutputTransform/HtmlHolder for instance) would also benefit from being able to use a consistent JSON serializer that supports deserialization to objects.

Desired features are: (a) highly performant, since it is on the critical path of cache hits for article read views, and (b) service-friendly, in case deserialization needs to consult a MediaWiki service, (c) compatible with existing serialization formats to allow transition of ParserCache contents.

A proposed implementation is in https://github.com/cscott/json-codec

Event Timeline

I believe the initial feedback on https://github.com/cscott/json-codec was that creating a new class codec for every class to be deserialized (as in https://github.com/cscott/json-codec/blob/f7bbad011d084dc4ede30bf6d1a47b853b8c64dd/src/JsonCodecableTrait.php#L48) might not meet the performance goals, but I think that can be easily patched.

Change 962673 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/vendor@master] Add wikimedia/json-codec 2.0.0

https://gerrit.wikimedia.org/r/962673

Change 962677 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/services/parsoid@master] Add wikimedia/json-codec to Parsoid dependencies

https://gerrit.wikimedia.org/r/962677

Change 963046 had a related patch set uploaded (by Jforrester; author: C. Scott Ananian):

[mediawiki/core@master] Add wikimedia/json-codec 2.2.1

https://gerrit.wikimedia.org/r/963046

Change 962673 merged by jenkins-bot:

[mediawiki/vendor@master] Add wikimedia/json-codec 2.2.1

https://gerrit.wikimedia.org/r/962673

Change 962677 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Add wikimedia/json-codec 2.2.1 to Parsoid dependencies

https://gerrit.wikimedia.org/r/962677

Change 966284 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.19.0-a2

https://gerrit.wikimedia.org/r/966284

Change 966284 merged by jenkins-bot:

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.19.0-a2

https://gerrit.wikimedia.org/r/966284

Change 963046 merged by jenkins-bot:

[mediawiki/core@master] Add wikimedia/json-codec 2.2.1

https://gerrit.wikimedia.org/r/963046

Change #975355 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] [JsonCodec] Add support for JsonCodecable

https://gerrit.wikimedia.org/r/975355

Change #1038445 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] [JsonCodec] Use wikimedia/json-codec to implement JsonCodec

https://gerrit.wikimedia.org/r/1038445

Change #975355 abandoned by C. Scott Ananian:

[mediawiki/core@master] [JsonCodec] Add support for JsonCodecable

Reason:

Squashed into Ia1017dcef462f3ac1ff5112106f7df81f5cc384f.

https://gerrit.wikimedia.org/r/975355