Index: trunk/extensions/LocalisationUpdate/tests/tokenTest.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | if( count( $args ) ) { |
34 | 34 | $sources = $args; |
35 | 35 | } else { |
36 | | - $sources = |
| 36 | + $sources = |
37 | 37 | array_merge( |
38 | 38 | glob("$IP/extensions/*/*.i18n.php"), |
39 | 39 | glob("$IP/languages/messages/Messages*.php") ); |
— | — | @@ -41,9 +41,9 @@ |
42 | 42 | foreach( $sources as $sourceFile ) { |
43 | 43 | $rel = basename( $sourceFile ); |
44 | 44 | $out = str_replace( '/', '-', $rel ); |
45 | | - |
| 45 | + |
46 | 46 | $sourceData = file_get_contents( $sourceFile ); |
47 | | - |
| 47 | + |
48 | 48 | if( preg_match( '!extensions/!', $sourceFile ) ) { |
49 | 49 | $sourceData = LocalisationUpdate::cleanupExtensionFile( $sourceData ); |
50 | 50 | $items = 'langs'; |
— | — | @@ -51,32 +51,32 @@ |
52 | 52 | $sourceData = LocalisationUpdate::cleanupFile( $sourceData ); |
53 | 53 | $items = 'messages'; |
54 | 54 | } |
55 | | - |
| 55 | + |
56 | 56 | file_put_contents( "$out.txt", $sourceData ); |
57 | 57 | |
58 | 58 | $start = microtime(true); |
59 | 59 | $eval = evalExtractArray( $sourceData, 'messages' ); |
60 | 60 | $deltaEval = microtime(true) - $start; |
61 | | - |
| 61 | + |
62 | 62 | $start = microtime(true); |
63 | 63 | $quick = quickTokenExtractArray( $sourceData, 'messages' ); |
64 | 64 | $deltaQuick = microtime(true) - $start; |
65 | | - |
| 65 | + |
66 | 66 | $start = microtime(true); |
67 | 67 | $token = confExtractArray( $sourceData, 'messages' ); |
68 | 68 | $deltaToken = microtime(true) - $start; |
69 | | - |
| 69 | + |
70 | 70 | $hashEval = md5(serialize($eval)); |
71 | 71 | $hashToken = md5(serialize($token)); |
72 | 72 | $hashQuick = md5(serialize($quick)); |
73 | 73 | $countEval = count( (array)$eval); |
74 | 74 | $countToken = count( (array)$token ); |
75 | 75 | $countQuick = count( (array)$quick ); |
76 | | - |
| 76 | + |
77 | 77 | printf( "%s %s %d $items - %0.1fms - eval\n", $rel, $hashEval, $countEval, $deltaEval * 1000 ); |
78 | 78 | printf( "%s %s %d $items - %0.1fms - QuickArrayReader\n", $rel, $hashQuick, $countQuick, $deltaQuick * 1000 ); |
79 | 79 | printf( "%s %s %d $items - %0.1fms - ConfEditor\n", $rel, $hashToken, $countToken, $deltaToken * 1000 ); |
80 | | - |
| 80 | + |
81 | 81 | if( $hashEval !== $hashToken || $hashEval !== $hashQuick ) { |
82 | 82 | echo "FAILED on $rel\n"; |
83 | 83 | file_put_contents( "$out-eval.txt", var_export( $eval, true ) ); |
Index: trunk/extensions/LocalisationUpdate/LocalisationUpdate.class.php |
— | — | @@ -111,7 +111,7 @@ |
112 | 112 | |
113 | 113 | // Create a full path. |
114 | 114 | // TODO: add support for $wgExtensionAssetsPath |
115 | | - $localfile = "$IP/extensions/$relfile"; |
| 115 | + // $localfile = "$IP/extensions/$relfile"; |
116 | 116 | |
117 | 117 | // Get the full SVN directory path. |
118 | 118 | // TODO: add support for $wgExtensionAssetsPath |
— | — | @@ -401,6 +401,10 @@ |
402 | 402 | return @$hashes[$file] !== $hash; |
403 | 403 | } |
404 | 404 | |
| 405 | + /** |
| 406 | + * @param $file |
| 407 | + * @param $hash |
| 408 | + */ |
405 | 409 | public static function saveHash( $file, $hash ) { |
406 | 410 | if ( is_null( self::$newHashes ) ) { |
407 | 411 | self::$newHashes = self::readFile( 'hashes' ); |
— | — | @@ -594,6 +598,7 @@ |
595 | 599 | * Logs a message. |
596 | 600 | * |
597 | 601 | * @param $log String |
| 602 | + * @param bool $verbose |
598 | 603 | */ |
599 | 604 | public static function myLog( $log, $verbose = true ) { |
600 | 605 | if ( !$verbose ) { |
— | — | @@ -621,6 +626,11 @@ |
622 | 627 | } |
623 | 628 | } |
624 | 629 | |
| 630 | + /** |
| 631 | + * @param $lang |
| 632 | + * @return string |
| 633 | + * @throws MWException |
| 634 | + */ |
625 | 635 | public static function filename( $lang ) { |
626 | 636 | global $wgLocalisationUpdateDirectory, $wgCacheDirectory; |
627 | 637 | |
— | — | @@ -635,6 +645,10 @@ |
636 | 646 | return "$dir/l10nupdate-$lang.cache"; |
637 | 647 | } |
638 | 648 | |
| 649 | + /** |
| 650 | + * @param $lang |
| 651 | + * @return mixed |
| 652 | + */ |
639 | 653 | public static function readFile( $lang ) { |
640 | 654 | if ( !isset( self::$filecache[$lang] ) ) { |
641 | 655 | $file = self::filename( $lang ); |
— | — | @@ -657,6 +671,11 @@ |
658 | 672 | return self::$filecache[$lang]; |
659 | 673 | } |
660 | 674 | |
| 675 | + /** |
| 676 | + * @param $lang |
| 677 | + * @param $var |
| 678 | + * @throws MWException |
| 679 | + */ |
661 | 680 | public static function writeFile( $lang, $var ) { |
662 | 681 | $file = self::filename( $lang ); |
663 | 682 | |