Page MenuHomePhabricator

Do not call Entity::setId() with an int parameter
Closed, ResolvedPublic

Description

Implementations of Entity::setId() should require an EntityId as a parameter. At present, they also support int parameters, and then create the appropriate EntityId internally. Besides this being a nasty B/C hack, it does not work for foreign IDs.

Support for numeric IDs can be removed from Entity::setId() by making all callers that use an integer construct an EntityId first, using the EntityIdComposer service. In particular, this is the case for WikiPageEntityStore::assignFreshId().

Event Timeline

daniel moved this task from To Do to Push on the User-Daniel board.

I triaged this as high because it is quite nasty, extremely old technical debt we want to pay for a long, long time. Luckily it became very easy to finally fix this with what we build in the past months. Just use the existing entity-id-composer-callbacks in WikiPageEntityStore::assignFreshId, and be done. I believe this will be the last instance of numeric calls to setId(). We can remove this feature from all entity types then! (Probably have some kind of deprecation phase for Item and Property.)

I believe this is not a blocker for any of the projects we are currently working on. MediaInfo already works around this issue.

Change 367024 had a related patch set uploaded (by AnotherLadsgroup; owner: Amir Sarabadani):
[mediawiki/extensions/Wikibase@master] Use EntityIdComposer instead of sending numeric id to EntityId::setId()

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

Change 367024 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Use EntityIdComposer instead of sending numeric id to EntityId::setId()

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

The callers are removed, but the implementation of setId() still accepts integers, and we still have tests using that. @Ladsgroup, can you look into that? This should be fixed for Item, Property, Lexeme, and MediaInfo.

The wikibase-datamodel will need a new release - technically, this is a breaking change, so it should go into the next major release. I don't see a reason to do a major release just for this, though... Do we have a marker for "next release needs to be major"? Having BREAKING in the commit message should do it, i guess...

Already on it, github PR has a tag for breaking we can use that.

Change 367461 had a related patch set uploaded (by AnotherLadsgroup; owner: Amir Sarabadani):
[mediawiki/extensions/WikibaseLexeme@master] Do not let Lexeme::setId accept int as Id

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

Change 367463 had a related patch set uploaded (by Ladsgroup; owner: Amir Sarabadani):
[mediawiki/extensions/WikibaseMediaInfo@master] Do not let MediaInfo::setId accept int as Id

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

Change 367461 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Do not let Lexeme::setId accept int as Id

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

Change 367463 merged by jenkins-bot:
[mediawiki/extensions/WikibaseMediaInfo@master] Do not let MediaInfo::setId accept int as Id

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

I suggest to mark this ticket as done, as soon as we don't use setId(int) in Wikibase* repositories and make release later when we have more changes.

@Aleksey_WMDE I agree, this ticket does not require the data model release. Just the code to be merged in all repos.

Ladsgroup moved this task from Review to Done on the Wikidata-Former-Sprint-Board board.

Change 378723 had a related patch set uploaded (by Thiemo Mättig (WMDE); owner: Thiemo Mättig (WMDE)):
[mediawiki/extensions/Wikibase@master] Make Wikibase code base compatible with current DataModel master

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

Change 378723 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Make Wikibase code base compatible with current DataModel master

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