Page MenuHomePhabricator

Hook parameters should not be passed by reference unless the parameter is documented to be replaceable
Open, Needs TriagePublic

Description

Several hooks (like e.g. PageContentSaveComplete) are currently called with parameters passed by reference, even though this is not necessary, not required per the specification of the hook, and actually dangerous: in many cases, such parameters cannot safely be replaced by a hook handler.

This behavior is probably a relict from PHP 3 times, when objects would be copied if not passed by references.

NOTE: this cannot be changed without first changing the signature of all hook handlers. Failing to do so will result in warnings like Warning: Parameter 1 to AbuseFilterHooks::onPageContentSaveComplete() expected to be a reference, value given.

Details

Related Gerrit Patches:
mediawiki/extensions/ConfirmEdit : masterStop passing objects by reference
mediawiki/core : masterhooks: Don't suggest to expect Article and User by reference
mediawiki/extensions/GrowthExperiments : masterStop passing objects by reference
mediawiki/extensions/Echo : masterStop passing objects by reference
mediawiki/extensions/ProofreadPage : masterStop passing objects by reference
mediawiki/extensions/Quiz : masterStop passing objects by reference
mediawiki/extensions/QuizTabulate : masterStop passing objects by reference
mediawiki/core : masterhooks: Do not document the Parser object to be passed by ref
mediawiki/core : masterhooks: Stop suggesting to pass objects by reference
mediawiki/extensions/XAnalytics : masterStop passing objects by reference
mediawiki/extensions/TocTree : masterStop passing objects by reference
mediawiki/extensions/TheWikipediaLibrary : masterStop passing objects by reference
mediawiki/extensions/Translate : masterStop passing objects by reference
mediawiki/extensions/TorBlock : masterStop passing objects by reference
mediawiki/extensions/TimedMediaHandler : masterStop passing objects by reference
mediawiki/extensions/FlaggedRevs : masterStop passing objects by reference
mediawiki/extensions/PageAssessments : masterStop passing objects by reference
mediawiki/extensions/WikimediaEditorTasks : masterStop passing objects by reference
mediawiki/extensions/TitleBlacklist : masterStop passing objects by reference
mediawiki/extensions/WikimediaEvents : masterStop passing objects by reference
mediawiki/extensions/TemplateStyles : masterStop passing objects by reference
mediawiki/extensions/timeline : masterStop passing objects by reference
mediawiki/extensions/Scribunto : masterStop passing objects by reference
mediawiki/extensions/wikihiero : masterStop passing objects by reference
mediawiki/extensions/SyntaxHighlight_GeSHi : masterStop passing objects by reference
mediawiki/extensions/SubPageList3 : masterStop passing objects by reference
mediawiki/extensions/SiteMatrix : masterStop passing objects by reference
mediawiki/extensions/MapSources : masterStop passing objects by reference
mediawiki/extensions/RelatedArticles : masterStop passing objects by reference
mediawiki/extensions/LiquidThreads : masterStop passing objects by reference
mediawiki/extensions/GeoData : masterStop passing objects by reference
mediawiki/extensions/Josa : masterStop passing objects by reference
mediawiki/extensions/intersection : masterStop passing objects by reference
mediawiki/extensions/Insider : masterStop passing objects by reference
mediawiki/extensions/InputBox : masterStop passing objects by reference
mediawiki/extensions/ImageMap : masterStop passing objects by reference
mediawiki/extensions/GeoCrumbs : masterStop passing objects by reference
mediawiki/extensions/FundraiserLandingPage : masterStop passing objects by reference
mediawiki/extensions/WikimediaIncubator : masterStop passing objects by reference
mediawiki/extensions/Score : masterStop passing objects by reference
mediawiki/extensions/RandomArea : masterStop passing objects by reference

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

I don't see how this is connected to the codebase of a specific extension, hence removing MediaWiki-extensions-Other. Feel free to clarify.

Change 551015 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/wikihiero@master] Stop passing objects by reference

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

Change 551018 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/WikimediaIncubator@master] Stop passing objects by reference

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

Change 551019 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/timeline@master] Stop passing objects by reference

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

Change 551020 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/TemplateStyles@master] Stop passing objects by reference

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

Change 551021 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/SyntaxHighlight_GeSHi@master] Stop passing objects by reference

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

Change 551022 had a related patch set uploaded (by Zoranzoki21; owner: Zoranzoki21):
[mediawiki/extensions/RandomArea@master] Stop passing objects by reference

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

Change 551022 merged by jenkins-bot:
[mediawiki/extensions/RandomArea@master] Stop passing objects by reference

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

Change 551025 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/SubPageList3@master] Stop passing objects by reference

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

Change 551028 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/SiteMatrix@master] Stop passing objects by reference

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

Change 551029 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/Scribunto@master] Stop passing objects by reference

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

Change 551030 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/Score@master] Stop passing objects by reference

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

Change 551031 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/RelatedArticles@master] Stop passing objects by reference

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

Change 551033 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/MapSources@master] Stop passing objects by reference

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

Change 551034 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/LiquidThreads@master] Stop passing objects by reference

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

Change 551043 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/Josa@master] Stop passing objects by reference

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

Change 551044 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/intersection@master] Stop passing objects by reference

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

Change 551045 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/Insider@master] Stop passing objects by reference

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

Change 551047 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/InputBox@master] Stop passing objects by reference

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

Change 551048 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/ImageMap@master] Stop passing objects by reference

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

Change 551049 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/GeoData@master] Stop passing objects by reference

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

Change 551056 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/GeoCrumbs@master] Stop passing objects by reference

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

Change 551057 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/FundraiserLandingPage@master] Stop passing objects by reference

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

Change 551030 merged by jenkins-bot:
[mediawiki/extensions/Score@master] Stop passing objects by reference

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

Change 551018 merged by jenkins-bot:
[mediawiki/extensions/WikimediaIncubator@master] Stop passing objects by reference

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

Change 551057 merged by jenkins-bot:
[mediawiki/extensions/FundraiserLandingPage@master] Stop passing objects by reference

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

Change 551056 merged by jenkins-bot:
[mediawiki/extensions/GeoCrumbs@master] Stop passing objects by reference

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

Change 551049 merged by jenkins-bot:
[mediawiki/extensions/GeoData@master] Stop passing objects by reference

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

Change 551048 merged by jenkins-bot:
[mediawiki/extensions/ImageMap@master] Stop passing objects by reference

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

Change 551047 merged by jenkins-bot:
[mediawiki/extensions/InputBox@master] Stop passing objects by reference

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

Change 551045 merged by jenkins-bot:
[mediawiki/extensions/Insider@master] Stop passing objects by reference

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

Change 551044 merged by jenkins-bot:
[mediawiki/extensions/intersection@master] Stop passing objects by reference

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

Change 551043 merged by jenkins-bot:
[mediawiki/extensions/Josa@master] Stop passing objects by reference

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

Change 551034 merged by jenkins-bot:
[mediawiki/extensions/LiquidThreads@master] Stop passing objects by reference

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

Change 551031 merged by jenkins-bot:
[mediawiki/extensions/RelatedArticles@master] Stop passing objects by reference

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

Change 551033 merged by jenkins-bot:
[mediawiki/extensions/MapSources@master] Stop passing objects by reference

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

Change 551028 merged by jenkins-bot:
[mediawiki/extensions/SiteMatrix@master] Stop passing objects by reference

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

Change 551029 merged by jenkins-bot:
[mediawiki/extensions/Scribunto@master] Stop passing objects by reference

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

Change 551025 merged by jenkins-bot:
[mediawiki/extensions/SubPageList3@master] Stop passing objects by reference

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

Change 551021 merged by jenkins-bot:
[mediawiki/extensions/SyntaxHighlight_GeSHi@master] Stop passing objects by reference

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

Change 551020 merged by jenkins-bot:
[mediawiki/extensions/TemplateStyles@master] Stop passing objects by reference

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

Change 551019 merged by jenkins-bot:
[mediawiki/extensions/timeline@master] Stop passing objects by reference

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

Change 551015 merged by jenkins-bot:
[mediawiki/extensions/wikihiero@master] Stop passing objects by reference

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

Change 551255 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/FlaggedRevs@master] Stop passing objects by reference

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

Change 551257 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/PageAssessments@master] Stop passing objects by reference

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

Change 551261 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/QuizTabulate@master] Stop passing objects by reference

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

Change 551262 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/Quiz@master] Stop passing objects by reference

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

Change 551276 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/WikimediaEvents@master] Stop passing objects by reference

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

Change 551277 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/XAnalytics@master] Stop passing objects by reference

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

Change 551279 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/WikimediaEditorTasks@master] Stop passing objects by reference

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

Change 551276 merged by jenkins-bot:
[mediawiki/extensions/WikimediaEvents@master] Stop passing objects by reference

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

Change 551292 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/Translate@master] Stop passing objects by reference

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

Change 551293 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/TorBlock@master] Stop passing objects by reference

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

Change 551294 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/TocTree@master] Stop passing objects by reference

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

Change 551295 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/TitleBlacklist@master] Stop passing objects by reference

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

Change 551296 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/TimedMediaHandler@master] Stop passing objects by reference

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

Change 551297 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/TheWikipediaLibrary@master] Stop passing objects by reference

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

Change 551295 merged by jenkins-bot:
[mediawiki/extensions/TitleBlacklist@master] Stop passing objects by reference

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

Change 551279 merged by jenkins-bot:
[mediawiki/extensions/WikimediaEditorTasks@master] Stop passing objects by reference

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

Change 551257 merged by jenkins-bot:
[mediawiki/extensions/PageAssessments@master] Stop passing objects by reference

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

Change 551255 merged by jenkins-bot:
[mediawiki/extensions/FlaggedRevs@master] Stop passing objects by reference

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

Change 551296 merged by jenkins-bot:
[mediawiki/extensions/TimedMediaHandler@master] Stop passing objects by reference

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

Change 551293 merged by jenkins-bot:
[mediawiki/extensions/TorBlock@master] Stop passing objects by reference

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

Change 551292 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] Stop passing objects by reference

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

Change 551297 merged by Daimona Eaytoy:
[mediawiki/extensions/TheWikipediaLibrary@master] Stop passing objects by reference

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

Change 551567 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[mediawiki/core@master] hooks: Stop suggesting to pass objects by reference

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

Change 551570 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[mediawiki/core@master] hooks: Don't suggest to expect Article and User by reference

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

Change 551569 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[mediawiki/core@master] hooks: Do not document the Parser object to be passed by ref

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

Change 551294 merged by jenkins-bot:
[mediawiki/extensions/TocTree@master] Stop passing objects by reference

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

Change 551277 merged by jenkins-bot:
[mediawiki/extensions/XAnalytics@master] Stop passing objects by reference

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

Change 551567 merged by jenkins-bot:
[mediawiki/core@master] hooks: Stop suggesting to pass objects by reference

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

Change 551569 merged by jenkins-bot:
[mediawiki/core@master] hooks: Do not document the Parser object to be passed by ref

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

Change 551705 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/ConfirmEdit@master] Stop passing objects by reference

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

Change 551706 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/GrowthExperiments@master] Stop passing objects by reference

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

Change 551707 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/ProofreadPage@master] Stop passing objects by reference

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

Change 551710 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/Echo@master] Stop passing objects by reference

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

Change 551262 merged by jenkins-bot:
[mediawiki/extensions/Quiz@master] Stop passing objects by reference

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

Change 551261 merged by jenkins-bot:
[mediawiki/extensions/QuizTabulate@master] Stop passing objects by reference

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

Change 551710 merged by jenkins-bot:
[mediawiki/extensions/Echo@master] Stop passing objects by reference

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

Change 551707 merged by jenkins-bot:
[mediawiki/extensions/ProofreadPage@master] Stop passing objects by reference

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

Change 551706 merged by jenkins-bot:
[mediawiki/extensions/GrowthExperiments@master] Stop passing objects by reference

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

Change 551570 abandoned by Thiemo Kreuz (WMDE):
hooks: Don't suggest to expect Article and User by reference

Reason:
I will redo this later.

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

Change 551705 merged by jenkins-bot:
[mediawiki/extensions/ConfirmEdit@master] Stop passing objects by reference

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