r47391 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47390‎ | r47391 | r47392 >
Date:23:00, 17 February 2009
Author:brion
Status:ok
Tags:
Comment:
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?
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Title.php
@@ -555,7 +555,7 @@
556556 * @return \type{\string} Namespace text
557557 */
558558 public function getNsText() {
559 - global $wgCanonicalNamespaceNames;
 559+ global $wgContLang, $wgCanonicalNamespaceNames;
560560
561561 if ( '' != $this->mInterwiki ) {
562562 // This probably shouldn't even happen. ohh man, oh yuck.
@@ -568,35 +568,6 @@
569569 return $wgCanonicalNamespaceNames[$this->mNamespace];
570570 }
571571 }
572 -
573 - return $this->getNsTextInternal( $this->mNamespace );
574 - }
575 -
576 - function getNsTextInternal( $namespace ) {
577 - global $wgContLang, $wgRequest, $wgTitle, $wgSlowGenderAliases;
578 - if( $namespace === NS_USER || $namespace === NS_USER_TALK ) {
579 - static $gender = null;
580 -
581 - $name = $this->getBaseText();
582 - if( !isset($gender[$name] ) ) {
583 - $gender[$name] = User::getDefaultOption( 'gender' );
584 -
585 - // wgTitle may not be defined
586 - $mytitle = isset( $wgTitle ) ? $wgTitle : Title::newFromText( $wgRequest->getVal( 'title' ) );
587 -
588 - // Check stuff
589 - if ( $wgSlowGenderAliases ||
590 - // Needs to be checked always to produce desired
591 - // effect when viewing user pages
592 - ( $mytitle && $name === $mytitle->getBaseText() ) ) {
593 -
594 - $user = User::newFromName( $name );
595 - if ( $user ) $gender[$name] = $user->getOption( 'gender' );
596 - }
597 - }
598 -
599 - return $wgContLang->getGenderNsText( $this->mNamespace, $gender[$name] );
600 - }
601572 return $wgContLang->getNsText( $this->mNamespace );
602573 }
603574 /**
@@ -611,14 +582,16 @@
612583 * @return \type{\string} Namespace text
613584 */
614585 public function getSubjectNsText() {
615 - return $this->getNsTextInternal( MWNamespace::getSubject( $this->mNamespace ) );
 586+ global $wgContLang;
 587+ return $wgContLang->getNsText( MWNamespace::getSubject( $this->mNamespace ) );
616588 }
617589 /**
618590 * Get the namespace text of the talk page
619591 * @return \type{\string} Namespace text
620592 */
621593 public function getTalkNsText() {
622 - return $this->getNsTextInternal( MWNamespace::getTalk( $this->mNamespace ) );
 594+ global $wgContLang;
 595+ return( $wgContLang->getNsText( MWNamespace::getTalk( $this->mNamespace ) ) );
623596 }
624597 /**
625598 * Could this title have a corresponding talk page?
Index: trunk/phase3/includes/DefaultSettings.php
@@ -2645,12 +2645,6 @@
26462646 $wgNamespaceAliases = array();
26472647
26482648 /**
2649 - * Whether to check correct gender for all titles. If false, correct gender
2650 - * alias is only fetched for wgTitle.
2651 - */
2652 -$wgSlowGenderAliases = true;
2653 -
2654 -/**
26552649 * Limit images on image description pages to a user-selectable limit. In order
26562650 * to reduce disk usage, limits can only be selected from a list.
26572651 * The user preference is saved as an array offset in the database, by default
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -99,18 +99,6 @@
100100 );
101101
102102 /**
103 - * Array of gender-based namespace aliases per namespace. Only NS_USER and
104 - * NS_USER_TALK works.
105 - *
106 - * Example:
107 - NS_USER => array(
108 - 'male' => 'Male_user',
109 - 'female' => 'Female_user',
110 - ),
111 - */
112 -$genderAliases = array();
113 -
114 -/**
115103 * Array of namespace aliases, mapping from name to NS_xxx index
116104 */
117105 $namespaceAliases = array();
Index: trunk/phase3/languages/Language.php
@@ -63,7 +63,7 @@
6464 'defaultUserOptionOverrides', 'linkTrail', 'namespaceAliases',
6565 'dateFormats', 'datePreferences', 'datePreferenceMigrationMap',
6666 'defaultDateFormat', 'extraUserToggles', 'specialPageAliases',
67 - 'imageFiles', 'genderAliases'
 67+ 'imageFiles'
6868 );
6969
7070 static public $mMergeableMapKeys = array( 'messages', 'namespaceNames', 'mathNames',
@@ -266,18 +266,6 @@
267267 }
268268
269269 /**
270 - * Like getNsText, but looks first if there is custom alias for given gender
271 - */
272 - function getGenderNsText( $index, $gender ) {
273 - $this->load();
274 - if ( isset( $this->genderAliases[$index][$gender] ) ) {
275 - return $this->genderAliases[$index][$gender];
276 - } else {
277 - return $this->getNsText( $index );
278 - }
279 - }
280 -
281 - /**
282270 * A convenience function that returns the same thing as
283271 * getNsText() except with '_' changed to ' ', useful for
284272 * producing output.
@@ -2341,7 +2329,7 @@
23422330 *
23432331 * @return array Dependencies, map of filenames to mtimes
23442332 */
2345 - static function loadLocalisation( $code, $disableCache = true ) {
 2333+ static function loadLocalisation( $code, $disableCache = false ) {
23462334 static $recursionGuard = array();
23472335 global $wgMemc, $wgEnableSerializedMessages, $wgCheckSerialized;
23482336
@@ -2609,12 +2597,6 @@
26102598 foreach ( $this->namespaceNames as $index => $name ) {
26112599 $this->mNamespaceIds[$this->lc($name)] = $index;
26122600 }
2613 - # Add gender aliases to the normal aliases table automatically
2614 - foreach ( $this->genderAliases as $index => $aliases ) {
2615 - foreach ( $aliases as $alias ) {
2616 - $this->namespaceAliases[$alias] = $index;
2617 - }
2618 - }
26192601 if ( $this->namespaceAliases ) {
26202602 foreach ( $this->namespaceAliases as $name => $index ) {
26212603 if ( $index === NS_PROJECT_TALK ) {
Index: trunk/phase3/RELEASE-NOTES
@@ -96,7 +96,6 @@
9797 * Localize time zone regions in Special:Preferences
9898 * Add NUMBEROFACTIVEUSERS magic word, which is like NUMBEROFUSERS, but uses
9999 the active users data from site_stats.
100 -* (bug 13040) Gender-aware user namespace aliases
101100 * Add a <link rel="canonical"> tag on redirected page views
102101 * Replace hardcoded '...' as indication of a truncation with the
103102 'ellipsis' message

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r46246* (bug 13040) Gender switch in user preferencesnikerabbit09:41, 26 January 2009
r46247* (bug 13040) {{GENDER:}} magic word for interface messagesnikerabbit09:48, 26 January 2009
r47196* (bug 13040) Gender-aware user namespace aliases...nikerabbit19:54, 12 February 2009
r47219bug 17477 and fix for r47196: Don't use global $title; this can work when exe...ialex17:50, 13 February 2009

Status & tagging log