Page MenuHomePhabricator

Wikimedia production MediaWiki extensions should use mediawiki.storage rather than access localStorage/sessionStorage directly
Open, Needs TriagePublic

Description

Follow-up T401978 and the new lint rule we added in https://github.com/wikimedia/eslint-plugin-mediawiki/issues/119. There's a few WMF-deployed repos that currently violate this new lint rule and should be fixed (or explicitly annotated with rationale, if they handle their own exceptions and must bypass mw.storage for some reason).

Scope

Event Timeline

Esanders subscribed.

I've removed the VE hits as they were calling ve.init.platform.sessionStorage which is already a wrapper around mw.storage (at least in ve-mw).

Krinkle updated the task description. (Show Details)
Krinkle updated the task description. (Show Details)
Krinkle subscribed.

Added background to ease triage in our team. I've marked CentralAuth as completed without a patch, because it already handles exceptions locally, and bypasses the abstraction because it is a raw inline script (bypassing ResourceLoader and thus cannot easily depend on a module).

anon-set.js is inline. ext.centralauth.centralautologin.js could in theory use another module (although it only uses localStorage.getItem() which I think isn't supposed to throw exceptions).

Added background to ease triage in our team. I've marked CentralAuth as completed without a patch, because it already handles exceptions locally, and bypasses the abstraction because it is a raw inline script (bypassing ResourceLoader and thus cannot easily depend on a module).

Per your own edit, there should be a patch that inlines the disables and they should be "explicitly annotated with rationale[s]".

Change #1206426 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/extensions/CentralAuth@master] build: Move mediawiki/no-storage disable inline and document reason

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

anon-set.js is inline. ext.centralauth.centralautologin.js could in theory use another module (although it only uses localStorage.getItem() which I think isn't supposed to throw exceptions).

localStorage.getItem() can throw as well, usually by way of the global localStorage getter (window.localStorage) throwing rather than the individual method. This is the same way that the document.cookie getter cant throw in certain privacy modes.

Change #1206426 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] build: Move mediawiki/no-storage disable inline and document reason

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

Change #1219539 had a related patch set uploaded (by Esanders; author: Esanders):

[mediawiki/extensions/UniversalLanguageSelector@master] Use mw.storage for previousLanguage storage

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

Change #1219592 had a related patch set uploaded (by Esanders; author: Esanders):

[mediawiki/extensions/PageTriage@master] Use mw.storage instead of localStorage directly

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

Change #1219592 merged by jenkins-bot:

[mediawiki/extensions/PageTriage@master] Use mw.storage instead of localStorage directly

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