r70727 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70726‎ | r70727 | r70728 >
Date:00:19, 9 August 2010
Author:soxred93
Status:ok
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/api/ApiFormatDump.php (added) (history)
  • /trunk/phase3/includes/api/ApiMain.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiFormatDump.php
@@ -0,0 +1,64 @@
 2+<?php
 3+/**
 4+ * API for MediaWiki 1.8+
 5+ *
 6+ * Created on August 8, 2010
 7+ *
 8+ * Copyright © 2010 Soxred93
 9+ *
 10+ * This program is free software; you can redistribute it and/or modify
 11+ * it under the terms of the GNU General Public License as published by
 12+ * the Free Software Foundation; either version 2 of the License, or
 13+ * (at your option) any later version.
 14+ *
 15+ * This program is distributed in the hope that it will be useful,
 16+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 18+ * GNU General Public License for more details.
 19+ *
 20+ * You should have received a copy of the GNU General Public License along
 21+ * with this program; if not, write to the Free Software Foundation, Inc.,
 22+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 23+ * http://www.gnu.org/copyleft/gpl.html
 24+ *
 25+ * @file
 26+ */
 27+
 28+if ( !defined( 'MEDIAWIKI' ) ) {
 29+ // Eclipse helper - will be ignored in production
 30+ require_once( 'ApiFormatBase.php' );
 31+}
 32+
 33+/**
 34+ * API PHP's var_dump() output formatter
 35+ * @ingroup API
 36+ */
 37+class ApiFormatDump extends ApiFormatBase {
 38+
 39+ public function __construct( $main, $format ) {
 40+ parent::__construct( $main, $format );
 41+ }
 42+
 43+ public function getMimeType() {
 44+ // This looks like it should be text/plain, but IE7 is so
 45+ // brain-damaged it tries to parse text/plain as HTML if it
 46+ // contains HTML tags. Using MIME text/text works around this bug
 47+ return 'text/text';
 48+ }
 49+
 50+ public function execute() {
 51+ ob_start();
 52+ var_dump( $this->getResultData() );
 53+ $result = ob_get_contents();
 54+ ob_end_clean();
 55+ $this->printText( $result );
 56+ }
 57+
 58+ public function getDescription() {
 59+ return 'Output data in PHP\'s var_dump() format' . parent::getDescription();
 60+ }
 61+
 62+ public function getVersion() {
 63+ return __CLASS__ . ': $Id$';
 64+ }
 65+}
Property changes on: trunk/phase3/includes/api/ApiFormatDump.php
___________________________________________________________________
Added: svn:eol-style
166 + native
Index: trunk/phase3/includes/api/ApiMain.php
@@ -100,7 +100,9 @@
101101 'txt' => 'ApiFormatTxt',
102102 'txtfm' => 'ApiFormatTxt',
103103 'dbg' => 'ApiFormatDbg',
104 - 'dbgfm' => 'ApiFormatDbg'
 104+ 'dbgfm' => 'ApiFormatDbg',
 105+ 'dump' => 'ApiFormatDump',
 106+ 'dumpfm' => 'ApiFormatDump',
105107 );
106108
107109 /**
Index: trunk/phase3/includes/AutoLoader.php
@@ -260,6 +260,7 @@
261261 'ApiFeedWatchlist' => 'includes/api/ApiFeedWatchlist.php',
262262 'ApiFormatBase' => 'includes/api/ApiFormatBase.php',
263263 'ApiFormatDbg' => 'includes/api/ApiFormatDbg.php',
 264+ 'ApiFormatDump' => 'includes/api/ApiFormatDump.php',
264265 'ApiFormatFeedWrapper' => 'includes/api/ApiFormatBase.php',
265266 'ApiFormatJson' => 'includes/api/ApiFormatJson.php',
266267 'ApiFormatPhp' => 'includes/api/ApiFormatPhp.php',
Index: trunk/phase3/RELEASE-NOTES
@@ -341,6 +341,7 @@
342342 * (bug 24330) Add &redirect parameter to ?action=edit
343343 * (bug 24722) For list=allusers&auprop=blockinfo, only show blockedby and blockreason if
344344 the user is actually blocked.
 345+* Add format=dump and format=dumpfm, outputs results in PHP's var_dump() format.
345346
346347 === Languages updated in 1.17 ===
347348

Status & tagging log