Page MenuHomePhabricator

Document visibility of TextContent::$mText
Closed, ResolvedPublic


The object property mText of the class TextContent is not declared, so it is implicitely public. The TextContent class is advertised as immutable, so it should be clear mText should not be externally modified.

But it would be better to declare the object property, either with @var @internal to keep its visibility public (for testing purposes), either with a protected or private visibility.

Existing code directly using this object property (there are some homonyms in ParserOutput and SearchResult, I hope I’ve not missed other non-false-positive occurences):

  • extensions (in the Wikimedia code repository):
    • WikiLexicalData (multiple occurences in includes/api/): only read, so it can be easily replaced by TextContent::getNativeData()
  • core/tests:

Event Timeline

Seb35 created this task.Jan 14 2017, 1:04 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 14 2017, 1:04 PM
Seb35 triaged this task as Low priority.Jan 14 2017, 1:06 PM
Seb35 added a subscriber: daniel.

I add you, Daniel, as author of the code.

Change 332043 had a related patch set uploaded (by Seb35):
Use getter instead of property

I think with the above patch, we can consider the direct usage of mText as resolved, even if the patch is not yet merged, i accordance with

Some notes: The fact that mText is undeclared is an oversight. It was always meant to be at least protected, if not private. Any direct usage is really a bug.

Also, I would really love to get rid of getNativeData, see T155582: Deprecate Content::getNativeData(), defined TextContent::getText() to replace it. .

Sorry for making a mess...

I'd prefer to make mText protected (or if possible even private) right now, and not go the @var @internal route. It seems unnecessary. Any code accessing mText directly should be either trivial to fix, or is broken by design.

Change 332043 merged by jenkins-bot:
[mediawiki/extensions/WikiLexicalData@master] Use getter instead of property

In the meantime, @Addshore added this property as protected rMWc9231ac. @daniel, I let you submit a patch if you prefer a private visibility, or close this task.

Re-checking mText with CodeSearch, there is also ApprovedRevs which directly uses TextContent::mText; I create a patch.

Seb35 closed this task as Resolved.Sep 20 2018, 4:06 PM
Seb35 claimed this task.

The property is now declared as protected. See also T155582 related to this task.