• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Not a bug \XF::dump() causes erros on ajax calls

Affected version
2.0.0 Beta 1

katsulynx

Well-known member
#1
When a method that makes use of \XF::dump() is called in an ajax call, the ajax will 'fail' and dump the whole output in an unreadable state into the console. Would there be a way to either just strip the \XF::dump() output from the console or deliver it to the frontend in a readable way?
 

Mike

XenForo developer
Staff member
#2
When you add debug code, you would need to determine the context in which it's going to be displayed and adjust how it's dumped to suit. That function dumps HTML, so it's not appropriate in a context returning JSON (or for viewing in a console). You should use a different method.
 

Chris D

XenForo developer
Staff member
#3
Only thing to add is you might have more luck with \XF::dumpSimple(); which is more equivalent to var_dump (and the dump function from Zend Framework).

It will still break the JSON output in most cases but the dump will be slightly more readable.

Other than that, using a proper debugger or logging to a file will help.

\XF\Util\File::log('filename', 'test');
 

katsulynx

Well-known member
#4
I managed to draw the necessary information out of the console whenever I needed it so far. It just caught me by surprise, when I added a dumper to a function and suddenly the post edit would no longer work, even though I was working on a - kind of - different location. So for as long as the context is known, it's not really an issue (for me), but it took me a few minutes to figure out what happened in the beforementioned case, because the context can certainly vary.