Page MenuHomePhabricator

Switch `Event::serializeExtra()` to use JSONCodec instead of PHP's `serialize()`
Closed, ResolvedPublic

Description

The extra Event array contains arbitrary data passed by extensions when calling Event::create(). This data is later serialized by PHP function serialize() which is proven to cause some troubles:

  • PHP cannot unserialize value when class doesn't exist any more (for example alias was removed)
  • PHP cannot unserialize values when class was changed (some values are required/do not exist/etc)
  • it allows code injections
  • most likely methods serialize() and unserialize will be deprecated in PHP9

Instead of using serialize we can use the JSONCodec and JSONCodecable interface to allow Mediawiki to serialize/deserialize objects without using native PHP methods. This approach still allows extensions to keep arbitrary data they need. In case when the objects stored in the extra are not serializable (for example see T391948) extension developers can update their objects to allow serialization.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change #1142641 had a related patch set uploaded (by Pmiazga; author: Pmiazga):

[mediawiki/extensions/Echo@master] Use JsonCodec to serialize Extra array

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

Change #1143080 had a related patch set uploaded (by Pmiazga; author: Pmiazga):

[mediawiki/extensions/Echo@master] Pass json serialized extra when initializing fake notification

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

Change #1143083 had a related patch set uploaded (by Pmiazga; author: Pmiazga):

[mediawiki/extensions/Echo@master] Tests should use json to serialize event extra

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

Change #1143083 abandoned by Pmiazga:

[mediawiki/extensions/Echo@master] Tests should use json to serialize event extra

Reason:

It looks like this has to be part of Id342d4289228485deb007324d63eccbbb0031533 and I cannot split those into two smaller PRs

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

Change #1143080 merged by jenkins-bot:

[mediawiki/extensions/Echo@master] Pass json serialized extra when initializing fake notification

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

Change #1142641 merged by jenkins-bot:

[mediawiki/extensions/Echo@master] Use JsonCodec to serialize Extra array

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

matmarex assigned this task to pmiazga.