Tim said we can phase out $wgUser in favor of RequestContext::getMain()->getUser()
https://www.facebook.com/brionv/posts/10151391376376852
We could use a PHP CodeSniffer sniff to report $wgUser should be replaced.
hashar | |
May 30 2013, 10:17 AM |
F11005: wgUserFB.png | |
Nov 22 2014, 1:42 AM |
Tim said we can phase out $wgUser in favor of RequestContext::getMain()->getUser()
https://www.facebook.com/brionv/posts/10151391376376852
We could use a PHP CodeSniffer sniff to report $wgUser should be replaced.
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Declined | None | T50963 Add sniff to detect usage of deprecated $wgUser | |||
Duplicate | None | T92726 Linker::formatTemplates needs a context | |||
Resolved | Nikerabbit | T51086 Title::moveTo depends on $wgUser |
Don't we already have a deprecation system in general? (both for methods and for globals). How is phpcs relevant?
With the proper configuration, accessing deprecated methods or globals, a PHP error is emitted.
And what is the "proper" configuration to react whenever $wgUser is referenced / accessed ?
(In reply to comment #2)
And what is the "proper" configuration to react whenever $wgUser is
referenced / accessed ?
The proper solution is to assert that no php errors/notices are emitted during our running of the installer, php unit tests and http requests.
Marking as wontfix and suggest further discussion be at bug 48002.
Timo that is not covering everything. We want to get rid of $wgUser and the easiest is to detect whether it is used in the code, a sniff is a trivial thing to add in.
Related URL: https://gerrit.wikimedia.org/r/69090 (Gerrit Change Ic3d5f082afefe761a24ab0822859a9ef88c61e02)
Created attachment 12564
FB preview
(In reply to comment #0)
Attaching for posterity's sake.
Attached:
So I guess that needs to be done directly in core instead of phpcs as Timo pointed out. Moving bugs under MediaWiki product.
Change 69090 abandoned by Hashar:
Implement DeprecatedGlobalSniff for $wgUser
Reason:
I do not knew about DeprecatedGlobals.php seems it would get the job done. I have moved the bug report https://bugzilla.wikimedia.org/show_bug.cgi?id=48963 under MediaWiki product.
The following patch is probably rather relevant.
https://gerrit.wikimedia.org/r/#/c/153399/
I am interested in working on this. Should the PHP CodeSniffer sniff for $wgUser and warn to use RequestContext::getMain()->getUser() instead? Also, should it be automatically replaceable using phpcbf?
@Aashaka my patch on https://gerrit.wikimedia.org/r/#/c/69090/ is the wrong approach. Reviewer hinted at DeprecatedGlobals.php.
We need the wgUser config for static functions as you can't do $this on static functions.