From 112f2e6a5012a665955689cafa16444853a9921f Mon Sep 17 00:00:00 2001 From: Ilmari Karonen Date: Thu, 27 Nov 2008 22:36:25 +0000 Subject: [PATCH] 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); } --- RELEASE-NOTES | 8 +++++--- includes/Defines.php | 14 ++++++++++++-- includes/Export.php | 4 +++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ef0d8bdc33..ace3374b78 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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. diff --git a/includes/Defines.php b/includes/Defines.php index d4dc987f57..eb97b36242 100644 --- a/includes/Defines.php +++ b/includes/Defines.php @@ -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); /**#@-*/ /** diff --git a/includes/Export.php b/includes/Export.php index 827561e7e9..e435a20017 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -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, -- 2.20.1