Page MenuHomePhabricator

var_dump() on various objects writes gigabytes of data and takes minutes to run
Closed, ResolvedPublic

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
Resolved tstarling
ResolvedJdforrester-WMF
ResolvedJoe
ResolvedDzahn
Resolvedhashar
ResolvedJdforrester-WMF
ResolvedLadsgroup
ResolvedMoritzMuehlenhoff
Resolvedjijiki
ResolvedMoritzMuehlenhoff
ResolvedTrizek-WMF
ResolvedDzahn
Resolved Gilles
ResolvedDzahn
ResolvedRequestPapaul
Resolvedjijiki
DeclinedNone
ResolvedDzahn
ResolvedDzahn
ResolvedPapaul
Resolved Cmjohnson
ResolvedRequest Cmjohnson
ResolvedRequestPapaul
ResolvedAndrew
ResolvedArielGlenn
ResolvedDzahn
ResolvedLegoktm
ResolvedPapaul
ResolvedDzahn
Declined Gilles
ResolvedVolans
ResolvedDzahn
ResolvedLegoktm
ResolvedPleaseStand
ResolvedJoe
Resolved tstarling
ResolvedArielGlenn
ResolvedJoe
Resolved tstarling
ResolvedJdforrester-WMF
ResolvedJdforrester-WMF
ResolvedLegoktm
ResolvedJdforrester-WMF
ResolvedDaimona
ResolvedDaimona
ResolvedJdforrester-WMF
ResolvedJoe
ResolvedJMeybohm
ResolvedJoe
ResolvedJoe
ResolvedJoe
ResolvedJoe
ResolvedKrinkle
ResolvedJoe
ResolvedClement_Goubert
ResolvedClement_Goubert
ResolvedClement_Goubert
ResolvedMainframe98
ResolvedJoe
ResolvedZabe

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 subscribed.

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.

Jdforrester-WMF changed the task status from Stalled to Open.Oct 6 2022, 12:17 PM
Jdforrester-WMF edited projects, added MediaWiki-General; removed Upstream.
Jdforrester-WMF subscribed.

This work is no longer stalled (and no longer Upstream).

Change 672845 restored by Jforrester:

[mediawiki/core@master] Add some helpers to filter properties out of var_dump()

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

Change 672845 merged by jenkins-bot:

[mediawiki/core@master] Add some helpers to filter properties out of var_dump()

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