Page MenuHomePhabricator

LinkTarget should have an equals() method
Open, Needs TriagePublic

Description

LinkTarget should provide an easy way to check whether two link targets are the same.

Event Timeline

Tgr created this task.Mar 15 2019, 8:09 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 15 2019, 8:09 PM

Tagging as MediaWiki-Decoupling since I don't think we have a MediaWiki component LinkTarget belongs to, and these abstract interface stem from (the predecessor of) the decoupling project.

Do you want to be able to compare a Title with a TitleValue? Or is this pure object comparison?

Change 497014 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[mediawiki/core@master] [WIP] LinkTarget: Provide an equals() method

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

Tgr added a comment.Mar 16 2019, 12:23 AM

Well, it's an interface so it shouldn't assume that the implementation is always the same (and at least during the transition from Title to TitleValue it might not be). Also even if the two objects are of the same type, pure object comparison is not really reliable: === will differentiate between two instances of the same title, and == will do a recursive field equality check which might fail if e.g. comparing a fully loaded and a not fully loaded Title.

Currently, Title::newFromLinkTarget( $left )->equals( Title::newFromLinkTarget( $right )) seems to be the only safe way to compare, but that's a bit of a hassle. (Granted, changing an interface is a hassle, too.)

Change 497014 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[mediawiki/core@master] [WIP] LinkTarget: Provide an equals() method

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