Page MenuHomePhabricator

Unexpected LogEntry.title() behavior
Closed, ResolvedPublic

Description

The naming of LogEntry.title() implies that it would return a string, however it returns a Page. At this point in time, I don't see a way to get the page of a LogEntry without using this method.
Should it be renamed to page() and have a real title() that returns data["title"]?

Event Timeline

Daviskr raised the priority of this task from to Low.
Daviskr updated the task description. (Show Details)
Daviskr added a project: Pywikibot.
Daviskr changed Security from none to None.
Daviskr subscribed.

The problem is that script outside of our control could use title() and relies on the fact that it actually returns a Page object. But apart from that you could call event.title().title() to get its title in string form.

One long term solution would be to deprecate the title() usage and add a page() method. Then with pywikibot 3 (currently we are working towards pywikibot 2) repurpose the title() method returning a string. To aid scripts in transition we could add a parameter like title(_no_parse=False) which must be explicitly set to True and it then already returns a string. In this case emit no deprecation warning yet but as soon as title() returns a string nevertheless.

Change 218931 had a related patch set uploaded (by XZise):
[IMPROV] LogEntry: page method instead of title

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

Change 218931 merged by jenkins-bot:
[IMPROV] LogEntry: page method instead of title

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

jayvdb assigned this task to XZise.
jayvdb removed a project: Patch-For-Review.

I think stalled is appropriate as my patch does not solve this issue but just makes it easier in the future to resolve it properly (by returning the title string in title()).

IMO .title() needs to be deleted, as it conflicts with str.title(), and the raw values should be properties rather than callables.

Even if we delete it/replace it by a property this would be tracked by this bug. And I agree that properties sound more appropriate as afaik all parameters have no other parameters. And it seems like a reversed DotReadableDict.

It is just one of many deprecations, for things that need to be removed. We should set up a new task to define what will be deprecated, when.

Xqt subscribed.

page() method replaces the title() method