r104891 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104890‎ | r104891 | r104892 >
Date:19:59, 1 December 2011
Author:danwe
Status:deferred
Tags:
Comment:
'$egArrayExtensionCompatbilityMode' renamed to '$egArraysCompatibilityMode'. Removed accidental $egArraysExpansionEscapeTemplates = null; from settings.
Modified paths:
  • /trunk/extensions/Arrays/Arrays.php (modified) (history)
  • /trunk/extensions/Arrays/Arrays_Settings.php (modified) (history)
  • /trunk/extensions/Arrays/RELEASE-NOTES (modified) (history)

Diff [purge]

Index: trunk/extensions/Arrays/RELEASE-NOTES
@@ -6,9 +6,9 @@
77 'ArrayExtension' is now simply called 'Arrays'. Therefore you have to adjust your LocalSettings.php.
88 - '#arrayindex' will only expand options/default when required.
99 - '#arraymerge', '#arrayunion', '#arraydiff' and '#arrayintersect' can handle multiple arrays now.
10 - - Compatibility mode variable '$egArrayExtensionCompatbilityMode' is set to false by default. See
11 - Version 1.4 alpha for further information. Further changes to the compatibility mode behavior
12 - in version 2.0:
 10+ - Compatibility mode variable '$egArraysCompatibilityMode' ('$egArrayExtensionCompatbilityMode' in
 11+ Version 1.4 alpha) is set to false by default. See Version 1.4 alpha for further information.
 12+ - Additional changes to the compatibility mode behavior in version 2.0 include:
1313 + '#arrayindex' will return its default also in case of existing index but empty value. This
1414 makes the function consistent with Variables '#var' and hash tables '#hashvalue'.
1515 + '#arraymerge', '#arrayunion', '#arraydiff' and '#arrayintersect' with only one array for
Index: trunk/extensions/Arrays/Arrays.php
@@ -78,7 +78,7 @@
7979 * @since 2.0
8080 */
8181 public static function init( Parser &$parser ) {
82 - global $egArrayExtensionCompatbilityMode;
 82+ global $egArraysCompatibilityMode;
8383 /*
8484 * store for arrays per Parser object. This will solve several bugs related to
8585 * 'ParserClearState' hook clearing all variables early in combination with certain
@@ -87,7 +87,7 @@
8888 $parser->mExtArrays = new self();
8989
9090 // initialize default separator for '#arrayprint'
91 - if( $egArrayExtensionCompatbilityMode ) {
 91+ if( $egArraysCompatibilityMode ) {
9292 // COMPATIBILITY-MODE
9393 self::$mDefaultSep = ', ';
9494 }
@@ -278,7 +278,7 @@
279279 * {{#arrayprint:b|<br/>|@@@|[[name::@@@]]}} -- make SMW links
280280 */
281281 static function pfObj_arrayprint( Parser &$parser, PPFrame $frame, $args ) {
282 - global $egArrayExtensionCompatbilityMode, $egArraysExpansionEscapeTemplates;
 282+ global $egArraysCompatibilityMode, $egArraysExpansionEscapeTemplates;
283283
284284 // Get Parameters
285285 $arrayId = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
@@ -301,7 +301,7 @@
302302
303303 if( $array === null ) {
304304 // array we want to print doesn't exist!
305 - if( ! $egArrayExtensionCompatbilityMode ) {
 305+ if( ! $egArraysCompatibilityMode ) {
306306 return '';
307307 } else {
308308 // COMPATIBILITY-MODE
@@ -313,7 +313,7 @@
314314
315315 foreach( $array as $val ) {
316316
317 - if( ! $egArrayExtensionCompatbilityMode ) {
 317+ if( ! $egArraysCompatibilityMode ) {
318318 // NO COMPATIBILITY-MODE
319319 /**
320320 * escape the array value so it won't destroy the users wiki markup expression.
@@ -351,7 +351,7 @@
352352 break;
353353 }
354354
355 - if( $egArrayExtensionCompatbilityMode || $egArraysExpansionEscapeTemplates === null ) {
 355+ if( $egArraysCompatibilityMode || $egArraysExpansionEscapeTemplates === null ) {
356356 // COMPATIBLITY-MODE:
357357 /*
358358 * don't leave the final parse to Parser::braceSubstitution() since there are some special cases where it
@@ -370,7 +370,7 @@
371371 * {{#arrayindex:arrayid|index}}
372372 */
373373 static function pfObj_arrayindex( Parser &$parser, PPFrame $frame, $args ) {
374 - global $egArrayExtensionCompatbilityMode;
 374+ global $egArraysCompatibilityMode;
375375
376376 // Get Parameters
377377 $arrayId = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
@@ -384,14 +384,14 @@
385385 // get value or null if it doesn't exist. Takes care of negative index as well
386386 $val = self::get( $parser )->getArrayValue( $arrayId, $index );
387387
388 - if( $val === null || ( $val === '' && !$egArrayExtensionCompatbilityMode ) ) {
 388+ if( $val === null || ( $val === '' && !$egArraysCompatibilityMode ) ) {
389389 // index doesn't exist, return default (parameter 3)!
390390 // without compatibility, also return default in case of empty string ''
391391
392392 // only expand default when needed
393393 $defaultOrOptions = trim( $frame->expand( $rawOptions ) );
394394
395 - if( $egArrayExtensionCompatbilityMode ) {
 395+ if( $egArraysCompatibilityMode ) {
396396 // COMPATIBILITY-MODE
397397 // now parse the options, and do posterior process on the created array
398398 $options = self::parse_options( $defaultOrOptions );
@@ -480,12 +480,12 @@
481481 }
482482 }
483483
484 - global $egArrayExtensionCompatbilityMode;
 484+ global $egArraysCompatibilityMode;
485485
486486 // no match! (Expand only when needed!)
487487 $no = isset( $args[4] )
488488 ? trim( $frame->expand( $args[4] ) )
489 - : $egArrayExtensionCompatbilityMode ? '-1' : ''; // COMPATIBILITY-MODE
 489+ : $egArraysCompatibilityMode ? '-1' : ''; // COMPATIBILITY-MODE
490490 return $no;
491491 }
492492
@@ -509,8 +509,8 @@
510510 $store = self::get( $parser );
511511
512512 if( $arrayId === null ) {
513 - global $egArrayExtensionCompatbilityMode;
514 - if( ! $egArrayExtensionCompatbilityMode ) { // COMPATIBILITY-MODE
 513+ global $egArraysCompatibilityMode;
 514+ if( ! $egArraysCompatibilityMode ) { // COMPATIBILITY-MODE
515515 $store->setArray( $arrayId_new );
516516 }
517517 return '';
@@ -591,8 +591,8 @@
592592 static function pf_arrayslice( Parser &$parser, $arrayId_new, $arrayId = null , $offset = 0, $length = null ) {
593593 $store = self::get( $parser );
594594 if( $arrayId === null ) {
595 - global $egArrayExtensionCompatbilityMode;
596 - if( ! $egArrayExtensionCompatbilityMode ) { // COMPATIBILITY-MODE
 595+ global $egArraysCompatibilityMode;
 596+ if( ! $egArraysCompatibilityMode ) { // COMPATIBILITY-MODE
597597 $store->setArray( $arrayId_new );
598598 }
599599 return '';
@@ -632,9 +632,9 @@
633633 * {{#arrayreset:arrayid1,arrayid2,...arrayidn}}
634634 */
635635 static function pfObj_arrayreset( Parser &$parser, PPFrame $frame, $args) {
636 - global $egArrayExtensionCompatbilityMode;
 636+ global $egArraysCompatibilityMode;
637637
638 - if( $egArrayExtensionCompatbilityMode && count( $args ) == 1 ) {
 638+ if( $egArraysCompatibilityMode && count( $args ) == 1 ) {
639639 /*
640640 * COMPATIBILITY-MODE: before arrays were separated by ';' which is an bad idea since
641641 * the ',' is an allowed character in array names!
@@ -839,9 +839,9 @@
840840 $lastArray = array();
841841 }
842842
843 - global $egArrayExtensionCompatbilityMode;
 843+ global $egArraysCompatibilityMode;
844844
845 - if( ! $operationRan && $egArrayExtensionCompatbilityMode
 845+ if( ! $operationRan && $egArraysCompatibilityMode
846846 && $operationFunc !== 'multi_arraymerge' // only exception was 'arraymerge'
847847 ) {
848848 /*
@@ -922,8 +922,8 @@
923923 || ! array_key_exists( $arrayId, $this->mArrays )
924924 || ! is_array( $this->mArrays[ $arrayId ] )
925925 ) {
926 - global $egArrayExtensionCompatbilityMode;
927 - if( $egArrayExtensionCompatbilityMode ) {
 926+ global $egArraysCompatibilityMode;
 927+ if( $egArraysCompatibilityMode ) {
928928 return "undefined array: $arrayId"; // COMPATIBILITY-MODE
929929 } else {
930930 return '';
Index: trunk/extensions/Arrays/Arrays_Settings.php
@@ -18,14 +18,13 @@
1919
2020 /**
2121 * Full compatbility to versions before 1.4.
22 - * Set to true by default since version 2.0.
23 - * Regretable, this one has a speclling error...
 22+ * Set to false by default since version 2.0.
2423 *
25 - * @since 1.4 alpha
 24+ * @since 2.0 (as '$egArrayExtensionCompatbilityMode' in 1.4 alpha)
2625 *
2726 * @var boolean
2827 */
29 -$egArrayExtensionCompatbilityMode = false;
 28+$egArraysCompatibilityMode = false;
3029
3130 /**
3231 * Contains a key-value pair list of characters that should be replaced by a template or parser function
@@ -33,8 +32,8 @@
3433 * including the values into the string which is being expanded afterwards, array values can't distract
3534 * the surounding MW code. Otherwise the array values themselves would be parsed as well.
3635 *
37 - * This has no effect in case $egArrayExtensionCompatbilityMode is set to false! If set to null, Arrays
38 - * will jump to compatbility mode behavior on this, independently from $egArrayExtensionCompatbilityMode.
 36+ * This has no effect in case $egArraysCompatibilityMode is set to false! If set to null, Arrays will
 37+ * jump to compatbility mode behavior on this, independently from $egArraysCompatibilityMode.
3938 *
4039 * @since 2.0
4140 *
@@ -45,5 +44,4 @@
4645 '|' => '{{!}}',
4746 '{{' => '{{((}}',
4847 '}}' => '{{))}}'
49 -);
50 -$egArraysExpansionEscapeTemplates = null;
\ No newline at end of file
 48+);
\ No newline at end of file

Status & tagging log