Page MenuHomePhabricator

API initializes user preferences on every request
Closed, ResolvedPublic


ApiMain by default always sets context language to that of user, which involves $user->getOption( 'language' ) which i turn calls User::loadOptions() which calls the UserGetDefaultOptions hook which is handled by many extensions, including the noticeably slow processing by Gadgets. Can the API lazy load it or maybe User can perform a minimal initialization for language only?

Event Timeline

MaxSem created this task.Dec 31 2014, 9:55 PM
MaxSem raised the priority of this task from to Needs Triage.
MaxSem updated the task description. (Show Details)
MaxSem added a subscriber: MaxSem.
Aklapper triaged this task as Low priority.Jan 2 2015, 1:48 PM
Anomie added a subscriber: Anomie.Jan 5 2015, 5:09 PM

I had originally wanted uselang=user to not be the default, but lots of people complained.

For User to perform a minimal initialization for language only, we'd basically have to make it so that the UserGetDefaultOptions and UserLoadOptions hooks couldn't affect the language preference. That seems liable to be problematic in the future.

Real lazy loading would also be a bit annoying (we'd either have to implement an ApiDerivativeContext just to override the one method, or find anyone who calls ->getContext() on an API object and fix them), so let's see if they'll let us get away with moving uselang=user into RequestContext itself and have the API just punt on it.

Change 182832 had a related patch set uploaded (by Anomie):
API: Avoid unstubbing User for language pref when not needed


Anomie claimed this task.Jan 5 2015, 8:46 PM
Anomie added a project: MediaWiki-Core-Team.
Anomie set Security to None.
Anomie moved this task from Backlog to Needs Review/Feedback on the MediaWiki-Core-Team board.

Change 182832 merged by jenkins-bot:
API: Avoid unstubbing User for language pref when not needed

MaxSem closed this task as Resolved.Jan 5 2015, 11:06 PM
bd808 moved this task from Done to Archive on the MediaWiki-Core-Team board.Jan 12 2015, 11:37 PM
Aklapper removed a subscriber: Anomie.Oct 16 2020, 5:43 PM