Hey Tpt,

Hi! I'm working on a new version of wikibase-api-php based on the WikibaseDataModel component (the idea is to let the bots based on wikibase-api-php edit the Entity object and, when it's done, push back the
changes to wikidata with the wbeditentity api). But, in order to make the conversion between Entity object and API representation (in the two directions) I need the code that is in the \Wikibase\lib\Serializer namespace of
the Wikibase extension. Do you think it's possible to move these classes into a stand alone component? They doesn't looks to have strong dependancies on the other parts of the Wikibase extension.

It would be nice to see some data access abstraction mechanism on top of our web API. So great to hear you are working on that \o/

There have been some emails about the serialization code mentioned lately, as it is causing a number of problems and is, as you noticed, not really reusable in its current state. What I'd like to see happen is this code being refactored and put into its own component. We now have a much better idea of how to do this cleanly going on our experiences with the serialization code for the Ask library. So while it is not extremely tricky of a think to do, it does require quite some work. And for now, we are sort of blocked on creating new components due to requirements of the WMF deployment process. It might still be some time before that is resolved.

Quoting myself from an email that was send last month on the internal list:

The old serialization and deserialization code (both db and external) in Lib\Serializers is causing a lot of problems. The remaining bad dependencies in DataModel are caused by it, and cannot be removed without design flaws in the serialization code being fixed. New code, such as the datatype id stuff described above, can also not be implemented properly without refactoring first. A lot of the code is static, it all violates SRP and does not do proper dependency injection. I suggest creating a new serialization and deserialization component for the objects defined by the DataModel. This component could be shipped together with DataModel itself (and reside in the same git repo). It would be build on top of the Serialization component [2] and would thus work similar to the serialization and deserialization code in Ask and WikibaseQuery, which has no known issues. This new component would then be used by Wikibase Repo and Wikibase Client instead of the code in lib, which would be removed. Some code build on top of the new component might need to be added in lib, as we might already have, or later on need, (de)serailization functionality that does not fit in the new component, which would only be dependent on DataModel (and its dependencies).

It has been clear to me for quite some time that this code is not ideal (I already send some mail about this in the context of WikibaseQuery). Only recently I realized that fixing this essentially blocks removal of the last really bad dependencies in DataModel. Since we are running into situations where we need to choose between increasing the mess or fixing it, I think it is high time we do the later.
 
[2] https://github.com/wikimedia/mediawiki-extensions-Serialization

Cheers

--
Jeroen De Dauw
http://www.bn2vs.com
Don't panic. Don't be evil. ~=[,,_,,]:3
--