Page MenuHomePhabricator

TheWikipediaLibrary needs updating for deprecation of PreferencesFactory::setUser()
Closed, ResolvedPublic

Description

What is the problem?

In T238466, the (Default)PreferencesFactory::setUser() method was removed.

It is currently used here by TheWikipediaLibrary Extension.

Therefore, at the moment, the notification will fail to appear when it should (and there will be an exception in the logs).

I believe the solution is:

  • Remove the use of setUser()
  • Instead, pass the $user object to the methods getGlobalPreferencesValues() and setGlobalPreferences()
Steps to reproduce problem
  1. On a wiki with TheWikipediaLibrary installed, modify the LocalSettings.php with:
$wgTwlSendNotifications = true;
$wgTwlEditCount = 1;
$wgTwlRegistrationDays = 1;

(You could probably set them to 0 instead, if necessary)

  1. Login as a user and perform any edit

Expected behavior: You see an echo notification welcoming you to The Wikipedia Library (you might need to refresh the page)
Observed behavior: You see no notification. The logs have an error of the form: Call to undefined method GlobalPreferences\GlobalPreferencesFactory::setUser()

Environment

Wiki(s): TheWikipediaLibrary 1.0.0 (3d27d28) 02:47, 2 June 2020; MediaWiki 1.35.0-alpha (abf2cf3); GlobalPreferences 0.1.2 (227b187) 00:38, 9 June 2020

Event Timeline

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

Change 643518 had a related patch set uploaded (by Aezell; owner: Aezell):
[mediawiki/extensions/TheWikipediaLibrary@master] Remove use of deprecated setUser

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

Change 643518 merged by jenkins-bot:
[mediawiki/extensions/TheWikipediaLibrary@master] Remove use of deprecated setUser

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