$wgTitle is by far the most evil global we have. It needs to go away. It constantly gets in the way of doing things properly, and people use it not knowing how bad it is.
Suggest we make killing this a higher priority. Other globals are bad too, but this one is really really bad.
----
There are various places across MW core and extensions that only //set// `$wgTitle`, not read from it. These are harmless enough.
More problematic are the remaining cases where code //reads from// `$wgTitle`:
**MediaWiki core**
- [[https://gerrit.wikimedia.org/g/mediawiki/core/+/6b062603d70702ee236eaaf6759fddfbbfda9f05/includes/Linker/Linker.php|Linker]] - used in the deprecated function `Linker::makeExternalLink`. Action required - remove uses of this function from extensions.
- [[https://gerrit.wikimedia.org/g/mediawiki/core/+/6b062603d70702ee236eaaf6759fddfbbfda9f05/includes/Language/MessageCache.php|MessageCache]] - logged in the `GlobalTitleFail` log
- [[https://gerrit.wikimedia.org/g/mediawiki/core/+/6b062603d70702ee236eaaf6759fddfbbfda9f05/includes/Context/RequestContext.php|RequestContext]] - logged in the `GlobalTitleFail` log
- [[https://gerrit.wikimedia.org/g/mediawiki/core/+/6b062603d70702ee236eaaf6759fddfbbfda9f05/includes/CommentFormatter/CommentParser.php|CommentParser]] - not logged. `$wgTitle` is used when various CommentFormatter method are called with `$selfLinkTarget === null`. Action required - deprecate `null` parameter values in CommentFormatter?
**WMF-deployed extensions**
- [[https://gerrit.wikimedia.org/g/mediawiki/extensions/SecurePoll/+/b23a93350fa215ddd21606ebdfd2afbf48190d46/includes/Entities/Entity.php|SecurePoll]]
- [[https://gerrit.wikimedia.org/g/mediawiki/extensions/Wikibase/+/c6edb0c0e2e5ae37e9e40ece3cb92f3671e0c9ec/repo/includes/RepoHooks.php|Wikibase]]
- [[https://gerrit.wikimedia.org/g/mediawiki/extensions/EntitySchema/+/48ae4126915232af7797fb5ac49fbc31da31b3cd/src/MediaWiki/Hooks/FormatAutocommentsHookHandler.php|EntitySchema]]
Note that the last two instances are in FormatAutocomments hooks. That hook may need improving so that the `$title` parameter is never null, or is null in fewer scenarios.
**Non-WMF-deployed extensions**
- [[https://codesearch.wmcloud.org/things/?q=%5C%24wgTitle%5Cb&files=%5C.php%24|a lot of them]]