First step in replacing NS_IMAGE with NS_FILE, to match the canonical name change...
authorIlmari Karonen <vyznev@users.mediawiki.org>
Thu, 27 Nov 2008 22:36:25 +0000 (22:36 +0000)
committerIlmari Karonen <vyznev@users.mediawiki.org>
Thu, 27 Nov 2008 22:36:25 +0000 (22:36 +0000)
This step simply defines the new constants NS_FILE and NS_FILE_TALK, retaining NS_IMAGE and NS_IMAGE_TALK as aliases, and makes them usable for export (which seems to be the only part of core that uses the NS_* names as strings).

The second step should be a global search-and-replace across core (other than Defines.php and Export.php).  I've already tried this locally, and there seem to be no problems.  This step should not touch extensions.

The third, optional step would be updating at least some extensions to use the new constant names as well.  This would generally require prepending the following compatibility snippet to the main extension file:

// The names NS_FILE and NS_FILE_TALK are new in MediaWiki v1.14
if( !defined('NS_FILE') || !defined('NS_FILE_TALK') ) {
define('NS_FILE', NS_IMAGE);
define('NS_FILE_TALK', NS_IMAGE_TALK);
}

RELEASE-NOTES
includes/Defines.php
includes/Export.php

index ef0d8bd..ace3374 100644 (file)
@@ -60,9 +60,11 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   on the user's real name if one is set. Defaults to false (use the username)
 * Removed the 'apiThumbCacheDir' option from $wgForeignFileRepos (only used in
   ForeignAPIRepo)
-* Image namespace and accompanying talk namespace renamed to File. For backward
-  compatibility purposes, Image still works. External tools may need to be
-  updated.
+* (bug 44) Image namespace and accompanying talk namespace renamed to File.
+  For backward compatibility purposes, Image still works. External tools may
+  need to be updated.
+* The constants NS_FILE and NS_FILE_TALK can now be used instead of NS_IMAGE and
+  NS_IMAGE_TALK.  The old constants are retained as aliases for compatibility.
 * MediaWiki can be forced to use private IPs forwarded by a proxy server by
   using $wgUsePrivateIPs.
 
index d4dc987..eb97b36 100644 (file)
@@ -52,8 +52,8 @@ define('NS_USER', 2);
 define('NS_USER_TALK', 3);
 define('NS_PROJECT', 4);
 define('NS_PROJECT_TALK', 5);
-define('NS_IMAGE', 6);
-define('NS_IMAGE_TALK', 7);
+define('NS_FILE', 6);
+define('NS_FILE_TALK', 7);
 define('NS_MEDIAWIKI', 8);
 define('NS_MEDIAWIKI_TALK', 9);
 define('NS_TEMPLATE', 10);
@@ -62,6 +62,16 @@ define('NS_HELP', 12);
 define('NS_HELP_TALK', 13);
 define('NS_CATEGORY', 14);
 define('NS_CATEGORY_TALK', 15);
+/**
+ * NS_IMAGE and NS_IMAGE_TALK are the pre-v1.14 names for NS_FILE and
+ * NS_FILE_TALK respectively, and are kept for compatibility.
+ *
+ * When writing code that should be compatible with older MediaWiki
+ * versions, either stick to the old names or define the new constants
+ * yourself, if they're not defined already.
+ */
+define('NS_IMAGE', NS_FILE);
+define('NS_IMAGE_TALK', NS_FILE_TALK);
 /**#@-*/
 
 /**
index 827561e..e435a20 100644 (file)
@@ -780,7 +780,9 @@ class DumpNamespaceFilter extends DumpFilter {
                        "NS_USER_TALK"      => NS_USER_TALK,
                        "NS_PROJECT"        => NS_PROJECT,
                        "NS_PROJECT_TALK"   => NS_PROJECT_TALK,
-                       "NS_IMAGE"          => NS_IMAGE,
+                       "NS_FILE"           => NS_FILE,
+                       "NS_FILE_TALK"      => NS_FILE_TALK,
+                       "NS_IMAGE"          => NS_IMAGE,  // NS_IMAGE is an alias for NS_FILE
                        "NS_IMAGE_TALK"     => NS_IMAGE_TALK,
                        "NS_MEDIAWIKI"      => NS_MEDIAWIKI,
                        "NS_MEDIAWIKI_TALK" => NS_MEDIAWIKI_TALK,