r93456 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93455‎ | r93456 | r93457 >
Date:10:53, 29 July 2011
Author:questpc
Status:deferred
Tags:
Comment:
Small improvement in interpretation script debug function
Modified paths:
  • /trunk/extensions/QPoll/qp_eval.php (modified) (history)
  • /trunk/extensions/QPoll/qp_user.php (modified) (history)

Diff [purge]

Index: trunk/extensions/QPoll/qp_eval.php
@@ -114,7 +114,7 @@
115115 # math
116116 'round', 'ceil', 'floor',
117117 # arrays
118 - 'is_array', 'array_search', 'count',
 118+ 'is_array', 'array_search', 'count', 'array_intersect', 'array_diff',
119119 # strings
120120 'trim', 'preg_match', 'preg_match_all', 'preg_split', 'qp_lc',
121121 # debug
Index: trunk/extensions/QPoll/qp_user.php
@@ -78,25 +78,38 @@
7979 );
8080 }
8181
82 -function qp_debug() {
 82+/**
 83+ * Interpretation script debug function
 84+ * @param $args array $args[0] - string message
 85+ * $args[1] - variable to dump (optional)
 86+ * $args[2] - bool true / false enable / disable output (optional)
 87+ */
 88+function qp_debug( /* $args */ ) {
8389 $args = func_get_args();
84 - if ( count( $args ) < 2 ) {
 90+ if ( count( $args ) < 1 ) {
8591 return;
8692 }
87 - list( $var_name, $var_value ) = $args;
 93+ $message = $args[0];
8894 $debug = true;
8995 if ( count( $args ) > 2 ) {
9096 $debug = $args[2];
9197 }
92 - if ( $debug === true) {
 98+ if ( $debug !== true) {
 99+ return;
 100+ }
 101+ if ( count( $args ) > 1 ) {
93102 ob_start();
94 - var_dump( $var_value );
 103+ var_dump( $args[1] );
95104 $var_value = ob_get_contents();
96105 ob_end_clean();
97 - wfDebugLog( 'qpoll', "{$var_name} = {$var_value}\n" );
 106+ $message = "{$message} = {$var_value}\n";
98107 }
 108+ wfDebugLog( 'qpoll', $message );
99109 }
100110
 111+/**
 112+ * Interpretation script text lowercase function (according to content language)
 113+ */
101114 function qp_lc( $text ) {
102115 global $wgContLang;
103116 return $wgContLang->lc( $text );

Status & tagging log