r93268 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93267‎ | r93268 | r93269 >
Date:14:29, 27 July 2011
Author:questpc
Status:deferred
Tags:
Comment:
Interpretation scripts debug and local string lowercase functions.
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_user.php
@@ -78,6 +78,30 @@
7979 );
8080 }
8181
 82+function qp_debug() {
 83+ $args = func_get_args();
 84+ if ( count( $args ) < 2 ) {
 85+ return;
 86+ }
 87+ list( $var_name, $var_value ) = $args;
 88+ $debug = true;
 89+ if ( count( $args ) > 2 ) {
 90+ $debug = $args[2];
 91+ }
 92+ if ( $debug === true) {
 93+ ob_start();
 94+ var_dump( $var_value );
 95+ $var_value = ob_get_contents();
 96+ ob_end_clean();
 97+ wfDebugLog( 'qpoll', "{$var_name} = {$var_value}\n" );
 98+ }
 99+}
 100+
 101+function qp_lc( $text ) {
 102+ global $wgContLang;
 103+ return $wgContLang->lc( $text );
 104+}
 105+
82106 /**
83107 * Extension's global settings and initializiers
84108 * should be purely static and preferrably have no constructor
@@ -184,6 +208,7 @@
185209 global $wgHooks;
186210 global $wgExtraNamespaces, $wgNamespaceProtection;
187211 global $wgGroupPermissions;
 212+ global $wgDebugLogGroups;
188213
189214 # core check and local / remote path
190215 self::coreRequirements();
@@ -280,6 +305,8 @@
281306 # into the source of interpretation scripts
282307 $wgGroupPermissions['sysop']['editinterpretation'] = true;
283308 $wgGroupPermissions['bureaucrat']['editinterpretation'] = true;
 309+
 310+ $wgDebugLogGroups['qpoll'] = 'qpoll_debug_log.txt';
284311 }
285312
286313 static function mediaWikiVersionCompare( $version, $operator = '<' ) {
Index: trunk/extensions/QPoll/qp_eval.php
@@ -114,9 +114,11 @@
115115 # math
116116 'round', 'trunc', 'ceil', 'floor',
117117 # arrays
118 - 'is_array', 'array_search',
 118+ 'is_array', 'array_search', 'count',
119119 # strings
120 - 'preg_match', 'preg_split'
 120+ 'trim', 'preg_match', 'preg_match_all', 'preg_split', 'qp_lc',
 121+ # debug
 122+ 'qp_debug'
121123 );
122124
123125 # disallowed superglobals
@@ -222,6 +224,12 @@
223225 * @return
224226 */
225227 static function selfCheck() {
 228+ # remove unavailable functions from allowed calls list
 229+ foreach ( self::$allowedCalls as $key => $fname ) {
 230+ if ( !function_exists( $fname ) ) {
 231+ self::$allowedCalls[$key] = null;
 232+ }
 233+ }
226234 # the following var is used to check access to extension's locals
227235 # in the eval scope
228236 $selfCheck = 1;

Status & tagging log