From a1422fa2be7fe9be675fb29cfcd4674191bd6295 Mon Sep 17 00:00:00 2001 From: X! Date: Mon, 9 Aug 2010 00:19:55 +0000 Subject: [PATCH] Add format=dump and format=dumpfm, outputs results in PHP's var_dump() format. Finding the type of a variable is a little annoying with txt, and dbg is a little bit harder to parse. --- RELEASE-NOTES | 1 + includes/AutoLoader.php | 1 + includes/api/ApiFormatDump.php | 64 ++++++++++++++++++++++++++++++++++ includes/api/ApiMain.php | 4 ++- 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 includes/api/ApiFormatDump.php diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 408bb95cf9..5cdabfb4be 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -341,6 +341,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 24330) Add &redirect parameter to ?action=edit * (bug 24722) For list=allusers&auprop=blockinfo, only show blockedby and blockreason if the user is actually blocked. +* Add format=dump and format=dumpfm, outputs results in PHP's var_dump() format. === Languages updated in 1.17 === diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index bc0e477ec2..fcf022f62c 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -260,6 +260,7 @@ $wgAutoloadLocalClasses = array( 'ApiFeedWatchlist' => 'includes/api/ApiFeedWatchlist.php', 'ApiFormatBase' => 'includes/api/ApiFormatBase.php', 'ApiFormatDbg' => 'includes/api/ApiFormatDbg.php', + 'ApiFormatDump' => 'includes/api/ApiFormatDump.php', 'ApiFormatFeedWrapper' => 'includes/api/ApiFormatBase.php', 'ApiFormatJson' => 'includes/api/ApiFormatJson.php', 'ApiFormatPhp' => 'includes/api/ApiFormatPhp.php', diff --git a/includes/api/ApiFormatDump.php b/includes/api/ApiFormatDump.php new file mode 100644 index 0000000000..6197563dd1 --- /dev/null +++ b/includes/api/ApiFormatDump.php @@ -0,0 +1,64 @@ +getResultData() ); + $result = ob_get_contents(); + ob_end_clean(); + $this->printText( $result ); + } + + public function getDescription() { + return 'Output data in PHP\'s var_dump() format' . parent::getDescription(); + } + + public function getVersion() { + return __CLASS__ . ': $Id$'; + } +} diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index bd85f5d6f4..b31ed6ab4e 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -100,7 +100,9 @@ class ApiMain extends ApiBase { 'txt' => 'ApiFormatTxt', 'txtfm' => 'ApiFormatTxt', 'dbg' => 'ApiFormatDbg', - 'dbgfm' => 'ApiFormatDbg' + 'dbgfm' => 'ApiFormatDbg', + 'dump' => 'ApiFormatDump', + 'dumpfm' => 'ApiFormatDump', ); /** -- 2.20.1