r78505 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78504‎ | r78505 | r78506 >
Date:18:32, 16 December 2010
Author:yaron
Status:deferred (Comments)
Tags:
Comment:
Fixed bug - added call to "global $wgVersion"
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormInputs.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_Utils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_Utils.php
@@ -475,6 +475,7 @@
476476 * Loads messages only for MediaWiki versions that need it (< 1.16)
477477 */
478478 public static function loadMessages() {
 479+ global $wgVersion;
479480 if ( version_compare( $wgVersion, '1.16', '<' ) ) {
480481 wfLoadExtensionMessages( 'SemanticForms' );
481482 }
Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.php
@@ -901,6 +901,7 @@
902902 // default to false - no need to check if it matches a 'false' word
903903 $vlc = strtolower( trim( $cur_value ) );
904904 // manually load SMW's message values, if they weren't loaded before
 905+ global $wgVersion;
905906 if ( version_compare( $wgVersion, '1.16', '<' ) ) {
906907 wfLoadExtensionMessages( 'SemanticMediaWiki' );
907908 }
Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php
@@ -751,6 +751,7 @@
752752 if ( count( $cur_value ) == 1 ) {
753753 // manually load SMW's message values here, in case they
754754 // didn't get loaded before
 755+ global $wgVersion;
755756 if ( version_compare( $wgVersion, '1.16', '<' ) ) {
756757 wfLoadExtensionMessages( 'SemanticMediaWiki' );
757758 }
@@ -768,6 +769,7 @@
769770 }
770771 $cur_value_in_template = $no;
771772 } elseif ( count( $cur_value ) == 2 ) {
 773+ global $wgVersion;
772774 if ( version_compare( $wgVersion, '1.16', '<' ) ) {
773775 wfLoadExtensionMessages( 'SemanticMediaWiki' );
774776 }

Comments

#Comment by Zakgreant (talk | contribs)   19:32, 16 December 2010

In formHTML, you should only call 'global $wgVersion;' once.

Within the scope of a given function, you only need a single call to 'global' to link a locally scoped variable to a globally scoped variable.

#Comment by Yaron K. (talk | contribs)   22:18, 17 December 2010

Well, it's within two different 'if' clauses... I don't know - this seems like too minor a detail to worry about; those lines will go away once MW < 1.16 is no longer supported.

#Comment by Zakgreant (talk | contribs)   22:45, 17 December 2010

It shouldn't have any realy negative effect – it's just messy and makes reviewers nervous. Well, "reviewers" is a big word here – it makes me nervous. :)

#Comment by Bryan (talk | contribs)   13:43, 18 December 2010

I think the global $wg version is the most commonly used. But we don't have a convention either way.

Status & tagging log