r104888 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104887‎ | r104888 | r104889 >
Date:19:44, 1 December 2011
Author:danwe
Status:deferred
Tags:
Comment:
Possible to active compatibility mode just for '#arrayprint' expenasion behavior by setting $egArraysExpansionEscapeTemplates (former $egArraysEscapeTemplates) to null.
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
@@ -16,7 +16,7 @@
1717 + Default separator for '#arrayprint' now is the languages default separator instead of ', '.
1818 + '#arrayprint' will no longer expand the given wiki markup twice. Instead, it will escape special
1919 characters of array values before they will be inserted into the markup. This way it won't be
20 - possible anymore that array values can break the functions output. '$egArraysEscapeTemplates'
 20+ possible anymore that array values can break the functions output. '$egArraysExpansionEscapeTemplates'
2121 defines which special characters should be escaped by which template/parser function
2222 + *** See 1.4 alpha for previous changes ***
2323 - '#arraydefine' option 'print' no longer supports 'print=print' and parameters beyond options.
Index: trunk/extensions/Arrays/Arrays.php
@@ -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;
 282+ global $egArrayExtensionCompatbilityMode, $egArraysExpansionEscapeTemplates;
283283
284284 // Get Parameters
285285 $arrayId = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
@@ -351,7 +351,7 @@
352352 break;
353353 }
354354
355 - if( $egArrayExtensionCompatbilityMode ) {
 355+ if( $egArrayExtensionCompatbilityMode || $egArraysExpansionEscapeTemplates === null ) {
356356 // COMPATIBLITY-MODE:
357357 /*
358358 * don't leave the final parse to Parser::braceSubstitution() since there are some special cases where it
@@ -1232,11 +1232,17 @@
12331233 * @return string
12341234 */
12351235 public static function escapeForExpansion( $string ) {
1236 - global $egArraysEscapeTemplates;
 1236+ global $egArraysExpansionEscapeTemplates;
 1237+
 1238+ if( $egArraysExpansionEscapeTemplates === null ) {
 1239+ return $string;
 1240+ }
 1241+
12371242 $string = strtr(
12381243 $string,
1239 - $egArraysEscapeTemplates
 1244+ $egArraysExpansionEscapeTemplates
12401245 );
 1246+
12411247 return $string;
12421248 }
12431249
Index: trunk/extensions/Arrays/Arrays_Settings.php
@@ -28,20 +28,22 @@
2929 $egArrayExtensionCompatbilityMode = false;
3030
3131 /**
32 - * Contains a key-value par list of characters that should be replaced by a template or parser function
 32+ * Contains a key-value pair list of characters that should be replaced by a template or parser function
3333 * call within array values included into an #arrayprint. By replacing these special characters before
34 - * including the values into the string which is being parsed afterwards, array values can't distract
 34+ * including the values into the string which is being expanded afterwards, array values can't distract
3535 * the surounding MW code. Otherwise the array values themselves would be parsed as well.
3636 *
37 - * This has no effect in case $egArrayExtensionCompatbilityMode is set to false!
 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.
3839 *
3940 * @since 2.0
4041 *
41 - * @var array
 42+ * @var array|null
4243 */
43 -$egArraysEscapeTemplates = array(
 44+$egArraysExpansionEscapeTemplates = array(
4445 '=' => '{{=}}',
4546 '|' => '{{!}}',
4647 '{{' => '{{((}}',
4748 '}}' => '{{))}}'
48 -);
\ No newline at end of file
 49+);
 50+$egArraysExpansionEscapeTemplates = null;
\ No newline at end of file

Status & tagging log