r44004 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44003‎ | r44004 | r44005 >
Date:22:36, 27 November 2008
Author:vyznev
Status:ok
Tags:
Comment:
First step in replacing NS_IMAGE with NS_FILE, to match the canonical name change (bug 44).

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);
}
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Defines.php (modified) (history)
  • /trunk/phase3/includes/Export.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Defines.php
@@ -52,8 +52,8 @@
5353 define('NS_USER_TALK', 3);
5454 define('NS_PROJECT', 4);
5555 define('NS_PROJECT_TALK', 5);
56 -define('NS_IMAGE', 6);
57 -define('NS_IMAGE_TALK', 7);
 56+define('NS_FILE', 6);
 57+define('NS_FILE_TALK', 7);
5858 define('NS_MEDIAWIKI', 8);
5959 define('NS_MEDIAWIKI_TALK', 9);
6060 define('NS_TEMPLATE', 10);
@@ -62,6 +62,16 @@
6363 define('NS_HELP_TALK', 13);
6464 define('NS_CATEGORY', 14);
6565 define('NS_CATEGORY_TALK', 15);
 66+/**
 67+ * NS_IMAGE and NS_IMAGE_TALK are the pre-v1.14 names for NS_FILE and
 68+ * NS_FILE_TALK respectively, and are kept for compatibility.
 69+ *
 70+ * When writing code that should be compatible with older MediaWiki
 71+ * versions, either stick to the old names or define the new constants
 72+ * yourself, if they're not defined already.
 73+ */
 74+define('NS_IMAGE', NS_FILE);
 75+define('NS_IMAGE_TALK', NS_FILE_TALK);
6676 /**#@-*/
6777
6878 /**
Index: trunk/phase3/includes/Export.php
@@ -780,7 +780,9 @@
781781 "NS_USER_TALK" => NS_USER_TALK,
782782 "NS_PROJECT" => NS_PROJECT,
783783 "NS_PROJECT_TALK" => NS_PROJECT_TALK,
784 - "NS_IMAGE" => NS_IMAGE,
 784+ "NS_FILE" => NS_FILE,
 785+ "NS_FILE_TALK" => NS_FILE_TALK,
 786+ "NS_IMAGE" => NS_IMAGE, // NS_IMAGE is an alias for NS_FILE
785787 "NS_IMAGE_TALK" => NS_IMAGE_TALK,
786788 "NS_MEDIAWIKI" => NS_MEDIAWIKI,
787789 "NS_MEDIAWIKI_TALK" => NS_MEDIAWIKI_TALK,
Index: trunk/phase3/RELEASE-NOTES
@@ -60,9 +60,11 @@
6161 on the user's real name if one is set. Defaults to false (use the username)
6262 * Removed the 'apiThumbCacheDir' option from $wgForeignFileRepos (only used in
6363 ForeignAPIRepo)
64 -* Image namespace and accompanying talk namespace renamed to File. For backward
65 - compatibility purposes, Image still works. External tools may need to be
66 - updated.
 64+* (bug 44) Image namespace and accompanying talk namespace renamed to File.
 65+ For backward compatibility purposes, Image still works. External tools may
 66+ need to be updated.
 67+* The constants NS_FILE and NS_FILE_TALK can now be used instead of NS_IMAGE and
 68+ NS_IMAGE_TALK. The old constants are retained as aliases for compatibility.
6769 * MediaWiki can be forced to use private IPs forwarded by a proxy server by
6870 using $wgUsePrivateIPs.
6971

Follow-up revisions

RevisionCommit summaryAuthorDate
r44121Step 2 in NS_IMAGE -> NS_FILE transition (bug 44) (WARNING: huge commit)....vyznev17:14, 1 December 2008
r44122bug 44 related change: NS_IMAGE -> NS_FILEsiebrand18:03, 1 December 2008
r44495(bug 44) Fix omission: Image -> File in namespace names for yue, zh-hans, and...siebrand11:11, 12 December 2008
r44508Manual exporting namespaces aliases from Betawiki (bug 44: renaming of Image ...ialex18:21, 12 December 2008

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r43639(bug 44) Rename Image namespace to File. Based on a patch by brion....siebrand21:27, 17 November 2008
r44001(bug 44) make 'Image' and 'Image_talk' compatibility aliases work for all lan...vyznev20:27, 27 November 2008

Status & tagging log