Last modified: 2013-11-15 11:08:04 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 T50173, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 48173 - Lua table serialization (dumping contents of a table) is really painful/annoying
Lua table serialization (dumping contents of a table) is really painful/annoying
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Scribunto (Other open bugs)
unspecified
All All
: Low enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks: 48176
  Show dependency treegraph
 
Reported: 2013-05-06 19:06 UTC by MZMcBride
Modified: 2013-11-15 11:08 UTC (History)
5 users (show)

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


Attachments

Description MZMcBride 2013-05-06 19:06:52 UTC
I'm trying to debug a Lua module. Here's my test input:

---
function test(frame)
	local t = {}
	t[1] = 2
	return t
end
print(test())
---

This input returns the string "table". This is really unhelpful and very annoying. I want to dump the table. The string "table" provides almost no value to me at all.

It would be very helpful to have a function that can print something similar to this:

---
print_table(t)
t = { 1 = 2 }
---

Looking around the Web, it seems that this is a fairly common issue in Lua:

* http://www.luafaq.org/#T1.15
* http://lua-users.org/wiki/TableSerialization
* http://stackoverflow.com/questions/9168058/lua-beginner-table-dump-to-console

I'd like for there to be a built-in function (similar to print_r or var_dump in PHP or the print statement in Python 2) that allows easy dumping/printing/serialization of a Lua table for debugging purposes.
Comment 1 Gerrit Notification Bot 2013-06-27 18:14:09 UTC
Change 70857 had a related patch set uploaded by Anomie:
Add mw.logObject

https://gerrit.wikimedia.org/r/70857
Comment 2 Gerrit Notification Bot 2013-07-26 05:17:28 UTC
Change 70857 merged by jenkins-bot:
Add mw.logObject

https://gerrit.wikimedia.org/r/70857
Comment 3 Brad Jorsch 2013-07-26 13:43:24 UTC
Change merged. It should be deployed to WMF wikis with 1.22wmf13.
Comment 4 Gerrit Notification Bot 2013-11-14 15:20:15 UTC
Change 95414 had a related patch set uploaded by MarkAHershberger:
Add mw.logObject

https://gerrit.wikimedia.org/r/95414
Comment 5 Gerrit Notification Bot 2013-11-14 16:47:01 UTC
Change 95414 abandoned by MarkAHershberger:
Add mw.logObject

https://gerrit.wikimedia.org/r/95414
Comment 6 Andre Klapper 2013-11-15 11:08:04 UTC
No open patches to review here (backport patches got abandoned), hence resetting status to RESOLVED FIXED. Backport_to_Stable flag might be set to "-" by hexmode.

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


Navigation
Links