r54989 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54988‎ | r54989 | r54990 >
Date:00:45, 14 August 2009
Author:brion
Status:deferred
Tags:
Comment:
Quickie test script to confirm that the data extraction is actually working correctly.
Caught a bug in ConfEditor with double-quoted strings containing apostropes, fixed in r54987 on trunk (merged to wmf-deployment)
Modified paths:
  • /trunk/extensions/LocalisationUpdate/tests (added) (history)
  • /trunk/extensions/LocalisationUpdate/tests/tokenTest.php (added) (history)

Diff [purge]

Index: trunk/extensions/LocalisationUpdate/tests/tokenTest.php
@@ -0,0 +1,52 @@
 2+<?php
 3+
 4+$IP = strval( getenv( 'MW_INSTALL_PATH' ) ) !== ''
 5+ ? getenv( 'MW_INSTALL_PATH' )
 6+ : realpath( dirname( __FILE__ ) . "/../../../" );
 7+
 8+require_once( "$IP/maintenance/commandLine.inc" );
 9+
 10+
 11+
 12+function evalExtractArray( $php, $varname ) {
 13+ eval( $php );
 14+ return @$$varname;
 15+}
 16+
 17+function confExtractArray( $php, $varname ) {
 18+ $ce = new ConfEditor("<?php $php");
 19+ $vars = $ce->getVars();
 20+ $retval = @$vars[$varname];
 21+ return $retval;
 22+}
 23+
 24+$sources = glob("$IP/languages/messages/Messages*.php");
 25+
 26+foreach( $sources as $sourceFile ) {
 27+ $sourceData = file_get_contents( $sourceFile );
 28+ $sourceData = preg_replace( "/<\\?php/", "", $sourceData );
 29+ $sourceData = preg_replace( "/\?" . ">/", "", $sourceData );
 30+
 31+ $start = microtime(true);
 32+ $eval = evalExtractArray( $sourceData, 'messages' );
 33+ $deltaEval = microtime(true) - $start;
 34+
 35+ $start = microtime(true);
 36+ $token = confExtractArray( $sourceData, 'messages' );
 37+ $deltaToken = microtime(true) - $start;
 38+
 39+ $hashEval = md5(serialize($eval));
 40+ $hashToken = md5(serialize($token));
 41+
 42+ $rel = wfRelativePath( $sourceFile, $IP );
 43+ printf( "%s %s %0.1f - eval\n", $rel, $hashEval, $deltaEval * 1000 );
 44+ printf( "%s %s %0.1f - token\n", $rel, $hashToken, $deltaToken * 1000 );
 45+
 46+ 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");
 50+ }
 51+}
 52+
 53+echo "ok\n";
Property changes on: trunk/extensions/LocalisationUpdate/tests/tokenTest.php
___________________________________________________________________
Name: svn:eol-style
154 + native

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r54987Fixed double-escaping bug in ConfEditor's handling of double-quoted strings....brion00:36, 14 August 2009

Status & tagging log