From 11a76d372293073b4d54e639e5cc3d30b1c4ed4e Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 17 Feb 2009 23:00:57 +0000 Subject: [PATCH] Revert r47196, r47219 "* (bug 13040) Gender-aware user namespace aliases" and followup Using $wgTitle in a Title member function in a weird way that makes no sense. What's this code trying to accomplish, and can it do it in a way that's not broken? --- RELEASE-NOTES | 1 - includes/DefaultSettings.php | 6 ----- includes/Title.php | 37 +++++-------------------------- languages/Language.php | 22 ++---------------- languages/messages/MessagesEn.php | 12 ---------- 5 files changed, 7 insertions(+), 71 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 4cbe771ebb..2efafb73dc 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -96,7 +96,6 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Localize time zone regions in Special:Preferences * Add NUMBEROFACTIVEUSERS magic word, which is like NUMBEROFUSERS, but uses the active users data from site_stats. -* (bug 13040) Gender-aware user namespace aliases * Add a tag on redirected page views * Replace hardcoded '...' as indication of a truncation with the 'ellipsis' message diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 9cdb2f582d..6d37c88a59 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2644,12 +2644,6 @@ $wgExtraNamespaces = NULL; */ $wgNamespaceAliases = array(); -/** - * Whether to check correct gender for all titles. If false, correct gender - * alias is only fetched for wgTitle. - */ -$wgSlowGenderAliases = true; - /** * Limit images on image description pages to a user-selectable limit. In order * to reduce disk usage, limits can only be selected from a list. diff --git a/includes/Title.php b/includes/Title.php index ae0f9867d8..c3f55656d2 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -555,7 +555,7 @@ class Title { * @return \type{\string} Namespace text */ public function getNsText() { - global $wgCanonicalNamespaceNames; + global $wgContLang, $wgCanonicalNamespaceNames; if ( '' != $this->mInterwiki ) { // This probably shouldn't even happen. ohh man, oh yuck. @@ -568,35 +568,6 @@ class Title { return $wgCanonicalNamespaceNames[$this->mNamespace]; } } - - return $this->getNsTextInternal( $this->mNamespace ); - } - - function getNsTextInternal( $namespace ) { - global $wgContLang, $wgRequest, $wgTitle, $wgSlowGenderAliases; - if( $namespace === NS_USER || $namespace === NS_USER_TALK ) { - static $gender = null; - - $name = $this->getBaseText(); - if( !isset($gender[$name] ) ) { - $gender[$name] = User::getDefaultOption( 'gender' ); - - // wgTitle may not be defined - $mytitle = isset( $wgTitle ) ? $wgTitle : Title::newFromText( $wgRequest->getVal( 'title' ) ); - - // Check stuff - if ( $wgSlowGenderAliases || - // Needs to be checked always to produce desired - // effect when viewing user pages - ( $mytitle && $name === $mytitle->getBaseText() ) ) { - - $user = User::newFromName( $name ); - if ( $user ) $gender[$name] = $user->getOption( 'gender' ); - } - } - - return $wgContLang->getGenderNsText( $this->mNamespace, $gender[$name] ); - } return $wgContLang->getNsText( $this->mNamespace ); } /** @@ -611,14 +582,16 @@ class Title { * @return \type{\string} Namespace text */ public function getSubjectNsText() { - return $this->getNsTextInternal( MWNamespace::getSubject( $this->mNamespace ) ); + global $wgContLang; + return $wgContLang->getNsText( MWNamespace::getSubject( $this->mNamespace ) ); } /** * Get the namespace text of the talk page * @return \type{\string} Namespace text */ public function getTalkNsText() { - return $this->getNsTextInternal( MWNamespace::getTalk( $this->mNamespace ) ); + global $wgContLang; + return( $wgContLang->getNsText( MWNamespace::getTalk( $this->mNamespace ) ) ); } /** * Could this title have a corresponding talk page? diff --git a/languages/Language.php b/languages/Language.php index 08767924e0..97f441babc 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -63,7 +63,7 @@ class Language { 'defaultUserOptionOverrides', 'linkTrail', 'namespaceAliases', 'dateFormats', 'datePreferences', 'datePreferenceMigrationMap', 'defaultDateFormat', 'extraUserToggles', 'specialPageAliases', - 'imageFiles', 'genderAliases' + 'imageFiles' ); static public $mMergeableMapKeys = array( 'messages', 'namespaceNames', 'mathNames', @@ -265,18 +265,6 @@ class Language { return isset( $ns[$index] ) ? $ns[$index] : false; } - /** - * Like getNsText, but looks first if there is custom alias for given gender - */ - function getGenderNsText( $index, $gender ) { - $this->load(); - if ( isset( $this->genderAliases[$index][$gender] ) ) { - return $this->genderAliases[$index][$gender]; - } else { - return $this->getNsText( $index ); - } - } - /** * A convenience function that returns the same thing as * getNsText() except with '_' changed to ' ', useful for @@ -2341,7 +2329,7 @@ class Language { * * @return array Dependencies, map of filenames to mtimes */ - static function loadLocalisation( $code, $disableCache = true ) { + static function loadLocalisation( $code, $disableCache = false ) { static $recursionGuard = array(); global $wgMemc, $wgEnableSerializedMessages, $wgCheckSerialized; @@ -2609,12 +2597,6 @@ class Language { foreach ( $this->namespaceNames as $index => $name ) { $this->mNamespaceIds[$this->lc($name)] = $index; } - # Add gender aliases to the normal aliases table automatically - foreach ( $this->genderAliases as $index => $aliases ) { - foreach ( $aliases as $alias ) { - $this->namespaceAliases[$alias] = $index; - } - } if ( $this->namespaceAliases ) { foreach ( $this->namespaceAliases as $name => $index ) { if ( $index === NS_PROJECT_TALK ) { diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index b82b7a3d5e..0456077b08 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -98,18 +98,6 @@ $namespaceNames = array( NS_CATEGORY_TALK => 'Category_talk', ); -/** - * Array of gender-based namespace aliases per namespace. Only NS_USER and - * NS_USER_TALK works. - * - * Example: - NS_USER => array( - 'male' => 'Male_user', - 'female' => 'Female_user', - ), - */ -$genderAliases = array(); - /** * Array of namespace aliases, mapping from name to NS_xxx index */ -- 2.20.1