r97481 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97480‎ | r97481 | r97482 >
Date:12:58, 19 September 2011
Author:reedy
Status:ok
Tags:
Comment:
REL1_18 MFT r97460, r97461, r97469, r97470, r97475
Modified paths:
  • /branches/REL1_18/phase3/includes/GenderCache.php (modified) (history)
  • /branches/REL1_18/phase3/includes/Title.php (modified) (history)
  • /branches/REL1_18/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: branches/REL1_18/phase3/includes/Title.php
@@ -639,9 +639,17 @@
640640 }
641641 }
642642
 643+ // Strip off subpages
 644+ $pagename = $this->getText();
 645+ if ( strpos( $pagename, '/' ) !== false ) {
 646+ list( $username , ) = explode( '/', $pagename, 2 );
 647+ } else {
 648+ $username = $pagename;
 649+ }
 650+
643651 if ( $wgContLang->needsGenderDistinction() &&
644652 MWNamespace::hasGenderDistinction( $this->mNamespace ) ) {
645 - $gender = GenderCache::singleton()->getGenderOf( $this->getText(), __METHOD__ );
 653+ $gender = GenderCache::singleton()->getGenderOf( $username, __METHOD__ );
646654 return $wgContLang->getGenderNsText( $this->mNamespace, $gender );
647655 }
648656
Property changes on: branches/REL1_18/phase3/includes/Title.php
___________________________________________________________________
Modified: svn:mergeinfo
649657 Merged /trunk/phase3/includes/Title.php:r97460-97461,97469-97470,97475
Index: branches/REL1_18/phase3/includes/GenderCache.php
@@ -96,14 +96,24 @@
9797 * @param $caller String: the calling method
9898 */
9999 public function doQuery( $users, $caller = '' ) {
 100+ $default = $this->getDefault();
 101+
 102+ foreach ( (array) $users as $index => $value ) {
 103+ $name = strtr( $value, '_', ' ' );
 104+ if ( isset( $this->cache[$name] ) ) {
 105+ // Skip users whose gender setting we already know
 106+ unset( $users[$index] );
 107+ } else {
 108+ $users[$index] = $name;
 109+ // For existing users, this value will be overwritten by the correct value
 110+ $this->cache[$name] = $default;
 111+ }
 112+ }
 113+
100114 if ( count( $users ) === 0 ) {
101115 return false;
102116 }
103117
104 - foreach ( (array) $users as $index => $value ) {
105 - $users[$index] = strtr( $value, '_', ' ' );
106 - }
107 -
108118 $dbr = wfGetDB( DB_SLAVE );
109119 $table = array( 'user', 'user_properties' );
110120 $fields = array( 'user_name', 'up_value' );
@@ -117,7 +127,6 @@
118128 }
119129 $res = $dbr->select( $table, $fields, $conds, $comment, $joins, $joins );
120130
121 - $default = $this->getDefault();
122131 foreach ( $res as $row ) {
123132 $this->cache[$row->user_name] = $row->up_value ? $row->up_value : $default;
124133 }
Index: branches/REL1_18/phase3/languages/Language.php
@@ -385,9 +385,19 @@
386386 * @since 1.18
387387 */
388388 function needsGenderDistinction() {
389 - global $wgExtraGenderNamespaces;
390 - $aliases = $wgExtraGenderNamespaces + self::$dataCache->getItem( $this->mCode, 'namespaceGenderAliases' );
391 - return count( $aliases ) > 0;
 389+ global $wgExtraGenderNamespaces, $wgExtraNamespaces;
 390+ if ( count( $wgExtraGenderNamespaces ) > 0 ) {
 391+ // $wgExtraGenderNamespaces overrides everything
 392+ return true;
 393+ } elseif( isset( $wgExtraNamespaces[NS_USER] ) && isset( $wgExtraNamespaces[NS_USER_TALK] ) ) {
 394+ /// @todo There may be other gender namespace than NS_USER & NS_USER_TALK in the future
 395+ // $wgExtraNamespaces overrides any gender aliases specified in i18n files
 396+ return false;
 397+ } else {
 398+ // Check what is in i18n files
 399+ $aliases = self::$dataCache->getItem( $this->mCode, 'namespaceGenderAliases' );
 400+ return count( $aliases ) > 0;
 401+ }
392402 }
393403
394404 /**

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r97460Partial solution for bug 30972 to avoid query flood....nikerabbit09:04, 19 September 2011
r97461* (bug 27398) Add $wgExtraGenderNamespaces for configured gendered namespacesnikerabbit10:43, 19 September 2011
r97469Fix typo from r97461, was breaking unit testsreedy11:31, 19 September 2011
r97470Remove comment from r97469reedy11:33, 19 September 2011
r97475Fixing bug 30973. Strip off subpages when determining the username who the cu...nikerabbit11:49, 19 September 2011

Status & tagging log