Page MenuHomePhabricator

var_dump() on various objects writes gigabytes of data and takes minutes to run
Open, Stalled, LowPublic

Description

For example, on my local test wiki:

$u = new User;
$u->isAllowed("read");
var_dump($u);

This took 8m50s to complete, with stdout redirected to /dev/null. The problem appears to be that the growth of DI patterns, as opposed to class static members, means that everything links to everything and so dumping various kinds of object leads to dumping the whole address space. In this case, breaking in with gdb after a few seconds, the stack trace shows:

  • User
  • UserAuthority
  • PermissionManager
  • SpecialPageFactory
  • Language
  • LanguageConverterFactory
  • Closure (LanguageConverterFactory::$defaultLanguage dumps its closure argument $services)
  • MediaWikiServices

Another route to MediaWikiServices is via ObjectFactory.

I think the solution is to use __debugInfo() to break links from value-like objects to service-like objects, and links from service-like objects to the service container.

Related Objects

StatusSubtypeAssignedTask
Stalledtstarling
StalledNone
StalledNone
StalledNone
OpenNone
Resolvedhashar
ResolvedJdforrester-WMF
ResolvedLadsgroup
ResolvedMoritzMuehlenhoff
Resolvedjijiki
ResolvedMoritzMuehlenhoff
ResolvedTrizek-WMF
ResolvedDzahn
ResolvedGilles
StalledDzahn
ResolvedRequestPapaul
Resolvedjijiki
DeclinedNone
ResolvedDzahn
OpenNone
ResolvedDzahn
ResolvedPapaul
ResolvedCmjohnson
Opendancy
OpenNone
ResolvedRequestCmjohnson
ResolvedRequestPapaul
ResolvedAndrew
ResolvedArielGlenn
ResolvedDzahn
ResolvedLegoktm
OpenNone
ResolvedPapaul
ResolvedDzahn
DeclinedGilles
ResolvedVolans
ResolvedDzahn
OpenNone

Event Timeline

If it's worth doing, it's worth overdoing, am I right?

Change 672845 had a related patch set uploaded (by Legoktm; owner: Tim Starling):
[mediawiki/core@master] [WIP] FilterDebugInfo

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

Legoktm assigned this task to tstarling.
Legoktm added a subscriber: Legoktm.

If it's worth doing, it's worth overdoing, am I right?

Successfully accomplished in my opinion. :D

Change 672845 abandoned by Tim Starling:
[mediawiki/core@master] Add some helpers to filter properties out of var_dump()

Reason:
Requires PHP 7.4

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

Legoktm changed the task status from Open to Stalled.Mar 22 2021, 5:58 PM

On Gerrit @tstarling wrote:

I filed https://bugs.php.net/bug.php?id=80894 . There's no easy work around that I can see. The best thing for it is to wait for PHP 7.4.