r54990 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54989‎ | r54990 | r54991 >
Date:01:05, 14 August 2009
Author:brion
Status:deferred
Tags:
Comment:
include extensions in tests; don't die when ConfEditor parsing hits an exception; try to avoid fatal error in eval()s from extension .i18n.php files attempting to require() or require_once() their .i18n.magic.php brothers, which fails because their paths are relative to __FILE__
Modified paths:
  • /trunk/extensions/LocalisationUpdate/tests/tokenTest.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LocalisationUpdate/tests/tokenTest.php
@@ -9,18 +9,28 @@
1010
1111
1212 function evalExtractArray( $php, $varname ) {
 13+ // a bunch of files use require()s which makes them un-eval'able
 14+ if( preg_match( '/^require(_once)?\(.*__FILE__/m', $php ) ) {
 15+ echo "File contains a path-relative 'require' call which cannot be fulfilled.\n";
 16+ return false;
 17+ }
1318 eval( $php );
1419 return @$$varname;
1520 }
1621
1722 function confExtractArray( $php, $varname ) {
18 - $ce = new ConfEditor("<?php $php");
19 - $vars = $ce->getVars();
20 - $retval = @$vars[$varname];
 23+ try {
 24+ $ce = new ConfEditor("<?php $php");
 25+ $vars = $ce->getVars();
 26+ $retval = @$vars[$varname];
 27+ } catch( Exception $e ) {
 28+ print $e . "\n";
 29+ $retval = null;
 30+ }
2131 return $retval;
2232 }
2333
24 -$sources = glob("$IP/languages/messages/Messages*.php");
 34+$sources = glob("$IP/extensions/*/*.i18n.php") + glob("$IP/languages/messages/Messages*.php");
2535
2636 foreach( $sources as $sourceFile ) {
2737 $sourceData = file_get_contents( $sourceFile );
@@ -43,9 +53,11 @@
4454 printf( "%s %s %0.1f - token\n", $rel, $hashToken, $deltaToken * 1000 );
4555
4656 if( $hashEval !== $hashToken ) {
47 - file_put_contents( 'eval.txt', var_export( $eval, true ) );
48 - file_put_contents( 'token.txt', var_export( $token, true ) );
49 - die("check eval.txt and token.txt\n");
 57+ echo "FAILED on $rel\n";
 58+ $out = str_replace( '/', '-', $rel );
 59+ file_put_contents( "$out-eval.txt", var_export( $eval, true ) );
 60+ file_put_contents( "$out-token.txt", var_export( $token, true ) );
 61+ #die("check eval.txt and token.txt\n");
5062 }
5163 }
5264

Status & tagging log