Page MenuHomePhabricator

Deprecate Content::getNativeData(), defined TextContent::getText() to replace it.
Open, Stalled, LowPublic

Description

Content::getNativeData() should be removed because it misguides calling code into making baseless assumptions about the return value, which cannot be used with confidence. This includes core and WMF-maintained extensions.

There is no good reason for Content::getNativeData() to exist, since it guarantees nothing about the structure or format of the content. The only sensible use cases are for textual content. For that use case, a more narrow method getText should be created in TextContent. Other code using getNativeData is conceptually flawed by definition, since the return value cannot be used confidently. Structured content models, like EntityContent in the Wikibase extension, should (and typically do) define their own specialized getter methods for the internal structure.

See the subtasks of this task for extensions to fix.

Subtasks T283667 to T283686 are WMF deployed extensions.

Subtasks T283687 to T283704 are extensions not deployed on WMF servers.


Extensions already fixed (before dedicated subtasks were created, for remaining extensions):

Details

ProjectBranchLines +/-Subject
mediawiki/extensions/FlexDiagramsmaster+2 -2
mediawiki/extensions/PageExchangemaster+1 -1
mediawiki/coreREL1_35+1 -1
mediawiki/coreREL1_39+117 -18
mediawiki/coreREL1_38+118 -18
mediawiki/coremaster+117 -18
mediawiki/extensions/CentralNoticemaster+17 -4
mediawiki/coremaster+21 -0
mediawiki/extensions/Gadgetsmaster+2 -1
mediawiki/extensions/Translatemaster+5 -5
mediawiki/extensions/Collectionmaster+1 -1
mediawiki/extensions/CollaborationKitmaster+98 -6
mediawiki/extensions/BlueSpiceInsertTemplatemaster+1 -1
mediawiki/extensions/Scribuntomaster+2 -2
mediawiki/extensions/Videomaster+1 -1
mediawiki/extensions/RSSmaster+1 -1
mediawiki/extensions/DidYouKnowmaster+1 -1
mediawiki/extensions/Lingomaster+2 -2
mediawiki/extensions/NotebookViewermaster+1 -1
mediawiki/extensions/OpenStackManagermaster+2 -2
mediawiki/extensions/EducationProgrammaster+2 -2
mediawiki/extensions/AbuseFiltermaster+1 -1
mediawiki/extensions/Babelmaster+1 -1
mediawiki/extensions/Echomaster+1 -1
mediawiki/coremaster+57 -59
mediawiki/coremaster+284 -108
mediawiki/coremaster+236 -66
Show related patches Customize query in gerrit

Related Objects

StatusSubtypeAssignedTask
StalledNone
ResolvedRussRogovetz
ResolvedRussRogovetz
OpenRussRogovetz
OpenRussRogovetz
ResolvedOttomata
ResolvedTK-999
ResolvedJayprakash12345
ResolvedLegoktm
ResolvedRussRogovetz
DeclinedNone
OpenRussRogovetz
ResolvedRussRogovetz
ResolvedPhysikerwelt
OpenRussRogovetz
ResolvedRussRogovetz
OpenRussRogovetz
ResolvedTheDJ
OpenRussRogovetz
ResolvedRussRogovetz
OpenRussRogovetz
ResolvedNone
ResolvedRussRogovetz
Resolvedaoxomoxoa
ResolvedRussRogovetz
ResolvedTinss
ResolvedRussRogovetz
OpenRussRogovetz
ResolvedRussRogovetz
ResolvedRussRogovetz
ResolvedYaron_Koren
ResolvedRussRogovetz
ResolvedRussRogovetz
OpenRussRogovetz
ResolvedPaladox
OpenNone
OpenNone
OpenNone
ResolvedTechwizzie
ResolvedYaron_Koren

Event Timeline

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

Change 499499 merged by jenkins-bot:
[mediawiki/extensions/RSS@master] Call method getText() instead of getNativeData()

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

Change 499501 merged by jenkins-bot:
[mediawiki/extensions/Scribunto@master] Call method getText() instead of getNativeData()

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

Change 499826 had a related patch set uploaded (by Holger Knust; owner: Holger Knust):
[mediawiki/extensions/CollaborationKit@master] Call method getText() instead of getNativeData()

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

Change 499826 merged by jenkins-bot:
[mediawiki/extensions/CollaborationKit@master] Call method getText() instead of getNativeData()

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

Aklapper changed the task status from Stalled to Open.Oct 19 2020, 4:34 PM

The previous comments don't explain who or what (task?) exactly this task is stalled on ("If a report is waiting for further input (e.g. from its reporter or a third party) and can currently not be acted on"). Hence resetting task status.

(Smallprint, as general orientation for task management: If you wanted to express that nobody is currently working on this task, then the assignee should be removed and/or priority could be lowered instead. If work on this task is blocked by another task, then that other task should be added via Edit Related Tasks...Edit Subtasks. If this task is stalled on an upstream project, then the Upstream tag should be added. If this task requires info from the task reporter, then there should be instructions which info is needed. If this task needs retesting, then the TestMe tag should be added. If this task is either out of scope and nobody should ever work on this, or nobody else managed to reproduce the problem described in this task, then this task should have the "Declined" status. If the task is valid but should not appear on some team's workboard, then the team project tag should be removed while the task has another active project tag.)

This tasks mixes core and extensions and is outdated, so it's rather impossible to get any idea of its status

Aklapper changed the task status from Open to Stalled.May 26 2021, 10:46 AM
Aklapper removed a project: Patch-Needs-Improvement.
Aklapper updated the task description. (Show Details)

Change 498474 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] Use getText() instead of getNativeData() for TextContent

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

Change 498469 merged by jenkins-bot:

[mediawiki/extensions/Gadgets@master] Use getText() instead of getNativeData()

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

Resetting deactivated assignee account.

Currently AbstractContent::getNativeData() is an abstract method given it is defined in the interface Content but not defined in AbstractContent.

In order to ease the removal of getNativeData() in subclasses of AbstractContent, like in Wikibase or Flow, I propose to define it as a concrete method in AbstractContent (and throwing a LogicException).

Change 827002 had a related patch set uploaded (by Seb35; author: Seb35):

[mediawiki/core@master] Define concrete method in order to deprecate it in subclasses

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

Change 827002 merged by jenkins-bot:

[mediawiki/core@master] Define concrete method in order to deprecate it in subclasses

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

Change 498480 abandoned by Ejegg:

[mediawiki/extensions/CentralNotice@master] Use getText() instead of deprecated getNativeData()

Reason:

Merged Ia57c456e528f95ac1ec754f which also fixes the issue

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

Change 885444 had a related patch set uploaded (by TK-999; author: TK-999):

[mediawiki/core@master] Fix XML dumps for content types with non-string getNativeData()

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

Change 885444 merged by jenkins-bot:

[mediawiki/core@master] Fix XML dumps for content types with non-string getNativeData()

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

Change 885845 had a related patch set uploaded (by TK-999; author: TK-999):

[mediawiki/extensions/Flow@master] Replace use of Content::getNativeData()

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

Change 885775 had a related patch set uploaded (by Reedy; author: TK-999):

[mediawiki/core@REL1_39] Fix XML dumps for content types with non-string getNativeData()

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

Change 885776 had a related patch set uploaded (by Reedy; author: TK-999):

[mediawiki/core@REL1_38] Fix XML dumps for content types with non-string getNativeData()

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

Change 885777 had a related patch set uploaded (by Reedy; author: TK-999):

[mediawiki/core@REL1_35] Fix XML dumps for content types with non-string getNativeData()

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

Change 885776 merged by jenkins-bot:

[mediawiki/core@REL1_38] Fix XML dumps for content types with non-string getNativeData()

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

Change 885775 merged by jenkins-bot:

[mediawiki/core@REL1_39] Fix XML dumps for content types with non-string getNativeData()

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

Change 885777 merged by jenkins-bot:

[mediawiki/core@REL1_35] Fix XML dumps for content types with non-string getNativeData()

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

Change 926298 had a related patch set uploaded (by Yaron Koren; author: Yaron Koren):

[mediawiki/extensions/PageExchange@master] Replace Content::getNativeData() with TextContent::getText()

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

Change 926298 merged by jenkins-bot:

[mediawiki/extensions/PageExchange@master] Replace Content::getNativeData() with TextContent::getText()

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

Change 926301 had a related patch set uploaded (by Yaron Koren; author: Yaron Koren):

[mediawiki/extensions/FlexDiagrams@master] Replace Content::getNativeData() with TextContent::getText()

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

Change 926301 merged by jenkins-bot:

[mediawiki/extensions/FlexDiagrams@master] Replace Content::getNativeData() with TextContent::getText()

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