Last modified: 2013-08-22 14:54:59 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T43244, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 41244 - Revision::getContentInternal() is not handling text load failure properly
Revision::getContentInternal() is not handling text load failure properly
Status: VERIFIED FIXED
Product: MediaWiki
Classification: Unclassified
ContentHandler (Other open bugs)
unspecified
All All
: Unprioritized normal (vote)
: ---
Assigned To: Wikidata bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-10-20 15:44 UTC by Liangent
Modified: 2013-08-22 14:54 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Liangent 2012-10-20 15:44:13 UTC
In that function, it calls $this->loadText() to load text. In loadText(), it calls self::getRevisionText() and it's said to "@return String: text the text requested or false on failure". When loading of text fails, loadText() returns false, then false is passed to $handler->unserializeContent(), causing exception "TextContent expects a string in the constructor."

TextContent expects a string in the constructor.
Backtrace:
#0 /home/liangent/code/gerrit/mediawiki/core/includes/content/WikitextContent.php(8): TextContent->__construct(false, 'wikitext')
#1 /home/liangent/code/gerrit/mediawiki/core/includes/content/ContentHandler.php(1185): WikitextContent->__construct(false)
#2 /home/liangent/code/gerrit/mediawiki/core/includes/Revision.php(979): WikitextContentHandler->unserializeContent(false, 'text/x-wiki')
#3 /home/liangent/code/gerrit/mediawiki/core/includes/Revision.php(921): Revision->getContentInternal()
#4 /home/liangent/code/gerrit/mediawiki/core/includes/Revision.php(897): Revision->getContent(1, NULL)
#5 /home/liangent/code/gerrit/mediawiki/core/extensions/Wikipedia/classes/WikipediaHooks.php(273): Revision->getText()
...
Comment 1 Sumana Harihareswara 2012-10-22 19:14:32 UTC
Liangent, about how often does this affect the end user, and under what circumstances?  Thanks for the report.
Comment 2 Jeroen De Dauw 2012-10-23 12:22:05 UTC
Liangent: thanks for pointing this out.

This looks like something that should be fixed but is at the same time not high priority, as it is about the nice handling of a failure case which should not happen to begin with. (Unless I misunderstand the issue, which is quite possible, as I did not look at it that much.)
Comment 3 Liangent 2012-10-23 12:53:17 UTC
(In reply to comment #2)
> Liangent: thanks for pointing this out.
> 
> This looks like something that should be fixed but is at the same time not high
> priority, as it is about the nice handling of a failure case which should not
> happen to begin with. (Unless I misunderstand the issue, which is quite
> possible, as I did not look at it that much.)

I'm running a bot using MediaWiki as a framework on Toolserver with replicated DB. Since text is not available in DB, when $rev->getText() is called, text is loaded from my modified Revision::loadText() via network to WMF server which has a higher chance to fail. In past, $rev->getText() returns false and my bot code can ignore that. Now my bot process is just killed.
Comment 4 Liangent 2012-10-23 12:56:42 UTC
It's possible to catch the exception and check for the string "TextContent expects a string in the constructor." (because I don't want to ignore other kinds of exceptions) but determining error type by looking at the human-readable error message sounds nasty.
Comment 6 Liangent 2012-10-24 00:19:46 UTC
(In reply to comment #5)
> https://gerrit.wikimedia.org/r/#/c/29597/

This makes the caller unable to distinguish loading failure or success with really blank content. See my use case above.
Comment 7 Sumana Harihareswara 2012-10-24 05:47:30 UTC
https://gerrit.wikimedia.org/r/#/c/29597/ has been merged.  Close bug as Fixed?
Comment 8 Liangent 2012-10-24 05:48:52 UTC
(In reply to comment #7)
> https://gerrit.wikimedia.org/r/#/c/29597/ has been merged.  Close bug as Fixed?

Not so satisfied with this resolution... see my comment above.
Comment 9 Aude 2012-10-24 06:33:56 UTC
I'll let Daniel take a look at that and see how we can handle these cases in a nicer way.  He will be back next week.
Comment 10 Sumana Harihareswara 2012-10-25 03:57:38 UTC
Reversion patchset https://gerrit.wikimedia.org/r/#/c/29800/
Comment 11 Daniel Kinzler 2012-10-29 17:50:14 UTC
Fix for master in I1e13de14.
Comment 12 Daniel Kinzler 2012-10-30 10:22:09 UTC
THIMC: As Liangent points out, the above patch does not restore the previous behavior of getText() to return false on failure. However, that was never documented behavior, and getText() itself is now deprecated. Because of this, I think it's fine not to try to restore that behavior (and return an empty string instead). The problem with returning fdalse on failure is that now, getText() calls getContent(), and getContent() will return null if the content failed to load or was not available to the desired audient - you can't tell which.
Comment 13 denny vrandecic 2013-08-22 14:54:59 UTC
Closed older resolved bugs as verified.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links