Page MenuHomePhabricator

Notice given when TextContent constructed with $text = false should name caller
Open, LowPublic

Description

The following notice is not useful, because it does not name the caller nor give a backtrace.

[03-Nov-2012 10:49:34 UTC] PHP Notice: TextContent constructed with $text = false! This may indicate an error in the caller's scope. [Called from TextContent::__construct in /www/translatewiki.net/w/includes/content/TextContent.php at line 37] in /www/translatewiki.net/w/includes/debug/Debug.php on line 283


Version: 1.21.x
Severity: normal
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=44898

Details

Reference
bz41735

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 1:09 AM
bzimport set Reference to bz41735.
bzimport added a subscriber: Unknown Object (MLST).

This uses wfWarn to issue a warning. If you want a traceback, set $wgDevelopmentWarnings to true. That triggers a PHP warning, which will be rendered to page output and/or written to the error log.

Where and when a traceback is included with a logged warning is a matter of configuring mediawiki and php.

Naming the caller is not practical, since the caller may just as well be ContentHandler::makeContent or something similarly unhelpful. To find the "interesting" caller, you really need a full stack trace.

Closing as WFM, because with $wgDevelopmentWarnings I see a stack trace. Note that $wgDevelopmentWarnings is enabled automatically in unit tests.

I'm sorry but what you are saying is not correct.

  1. wfWarn has offset parameter to specify the caller. It might not always be useful, but showing TextContent::__construct is certainly not helpful.
  1. $wgDevelopmentWarnings only decides whether to show the warning or not. By reading the code we can see that wfWarn calls only either wfDebug or trigger_error, and neither displays the backtrace with any MediaWiki configuration.
  1. The only way to get PHP print backtraces for warnings and errors is the xdebug extension, which I don't have.

For 1) i could set the offset to 2, which will provide slightly more info in some cases, but I doubt that it would be useful.

Items 2) and 3) are general issues with MediaWiki's warning/logging system. That could be improved, but that's unrelated to the issue at hand.

  1. would be enough for me to close this bug. Another bug would be to optionally use wfBacktrace() in wfWarn.

Hasn't improved enough over the years:

PHP Notice:  TextContent constructed with $text = NULL! This may indicate an error in the caller's scope. [Called from WikitextContent::__construct in /srv/mediawiki/workdir/includes/content/WikitextContent.php at line 51] in /srv/mediawiki/workdir/includes/debug/MWDebug.php on line 507