r69714 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69713‎ | r69714 | r69715 >
Date:04:00, 22 July 2010
Author:tstarling
Status:ok (Comments)
Tags:
Comment:
Use $wgContLang not $wgLang for checkTitleEncoding() and getSpecialPageAliases(), it doesn't make sense to use the user language, WebRequest and SpecialPage certainly don't. The DatabaseOracle use of checkTitleEncoding() is weird and probably broken, but at least it uses the right object now.
Modified paths:
  • /trunk/phase3/includes/api/ApiQuerySiteinfo.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseOracle.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabaseOracle.php
@@ -457,7 +457,7 @@
458458 }
459459
460460 private function insertOneRow( $table, $row, $fname ) {
461 - global $wgLang;
 461+ global $wgContLang;
462462
463463 $table = $this->tableName( $table );
464464 // "INSERT INTO tables (a, b, c)"
@@ -493,7 +493,7 @@
494494 $val = '31-12-2030 12:00:00.000000';
495495 }
496496
497 - $val = ( $wgLang != null ) ? $wgLang->checkTitleEncoding( $val ) : $val;
 497+ $val = ( $wgContLang != null ) ? $wgContLang->checkTitleEncoding( $val ) : $val;
498498 if ( oci_bind_by_name( $stmt, ":$col", $val ) === false ) {
499499 $this->reportQueryError( $this->lastErrno(), $this->lastError(), $sql, __METHOD__ );
500500 return false;
@@ -1028,9 +1028,9 @@
10291029 }
10301030
10311031 function addQuotes( $s ) {
1032 - global $wgLang;
1033 - if ( isset( $wgLang->mLoaded ) && $wgLang->mLoaded ) {
1034 - $s = $wgLang->checkTitleEncoding( $s );
 1032+ global $wgContLang;
 1033+ if ( isset( $wgContLang->mLoaded ) && $wgContLang->mLoaded ) {
 1034+ $s = $wgContLang->checkTitleEncoding( $s );
10351035 }
10361036 return "'" . $this->strencode( $s ) . "'";
10371037 }
@@ -1040,7 +1040,7 @@
10411041 }
10421042
10431043 function selectRow( $table, $vars, $conds, $fname = 'DatabaseOracle::selectRow', $options = array(), $join_conds = array() ) {
1044 - global $wgLang;
 1044+ global $wgContLang;
10451045
10461046 $conds2 = array();
10471047 $conds = ($conds != null && !is_array($conds)) ? array($conds) : $conds;
@@ -1048,9 +1048,9 @@
10491049 $col_info = $this->fieldInfoMulti( $table, $col );
10501050 $col_type = $col_info != false ? $col_info->type() : 'CONSTANT';
10511051 if ( $col_type == 'CLOB' ) {
1052 - $conds2['TO_CHAR(' . $col . ')'] = $wgLang->checkTitleEncoding( $val );
 1052+ $conds2['TO_CHAR(' . $col . ')'] = $wgContLang->checkTitleEncoding( $val );
10531053 } elseif ( $col_type == 'VARCHAR2' && !mb_check_encoding( $val ) ) {
1054 - $conds2[$col] = $wgLang->checkTitleEncoding( $val );
 1054+ $conds2[$col] = $wgContLang->checkTitleEncoding( $val );
10551055 } else {
10561056 $conds2[$col] = $val;
10571057 }
@@ -1103,24 +1103,24 @@
11041104 }
11051105
11061106 public function delete( $table, $conds, $fname = 'DatabaseOracle::delete' ) {
1107 - global $wgLang;
 1107+ global $wgContLang;
11081108
1109 - if ( $wgLang != null ) {
 1109+ if ( $wgContLang != null ) {
11101110 $conds2 = array();
11111111 $conds = ($conds != null && !is_array($conds)) ? array($conds) : $conds;
11121112 foreach ( $conds as $col => $val ) {
11131113 $col_info = $this->fieldInfoMulti( $table, $col );
11141114 $col_type = $col_info != false ? $col_info->type() : 'CONSTANT';
11151115 if ( $col_type == 'CLOB' ) {
1116 - $conds2['TO_CHAR(' . $col . ')'] = $wgLang->checkTitleEncoding( $val );
 1116+ $conds2['TO_CHAR(' . $col . ')'] = $wgContLang->checkTitleEncoding( $val );
11171117 } else {
11181118 if ( is_array( $val ) ) {
11191119 $conds2[$col] = $val;
11201120 foreach ( $conds2[$col] as &$val2 ) {
1121 - $val2 = $wgLang->checkTitleEncoding( $val2 );
 1121+ $val2 = $wgContLang->checkTitleEncoding( $val2 );
11221122 }
11231123 } else {
1124 - $conds2[$col] = $wgLang->checkTitleEncoding( $val );
 1124+ $conds2[$col] = $wgContLang->checkTitleEncoding( $val );
11251125 }
11261126 }
11271127 }
Index: trunk/phase3/includes/api/ApiQuerySiteinfo.php
@@ -99,7 +99,7 @@
100100 }
101101
102102 protected function appendGeneralInfo( $property ) {
103 - global $wgContLang, $wgLang;
 103+ global $wgContLang;
104104
105105 $data = array();
106106 $mainPage = Title::newMainPage();
@@ -128,7 +128,7 @@
129129 if ( $wgContLang->isRTL() ) {
130130 $data['rtl'] = '';
131131 }
132 - $data['fallback8bitEncoding'] = $wgLang->fallback8bitEncoding();
 132+ $data['fallback8bitEncoding'] = $wgContLang->fallback8bitEncoding();
133133
134134 if ( wfReadOnly() ) {
135135 $data['readonly'] = '';
@@ -209,9 +209,9 @@
210210 }
211211
212212 protected function appendSpecialPageAliases( $property ) {
213 - global $wgLang;
 213+ global $wgContLang;
214214 $data = array();
215 - foreach ( $wgLang->getSpecialPageAliases() as $specialpage => $aliases )
 215+ foreach ( $wgContLang->getSpecialPageAliases() as $specialpage => $aliases )
216216 {
217217 $arr = array( 'realname' => $specialpage, 'aliases' => $aliases );
218218 $this->getResult()->setIndexedTagName( $arr['aliases'], 'alias' );

Comments

#Comment by Catrope (talk | contribs)   10:06, 22 July 2010
+		if ( isset( $wgContLang->mLoaded ) && $wgContLang->mLoaded ) {

Not introduced in this rev, I know, but this is ugly and should die.

+		if ( $wgContLang != null ) {

Really? When does that happen?

#Comment by MZMcBride (talk | contribs)   01:06, 9 August 2010

Bump: were these questions/issues answered/addressed elsewhere?

#Comment by Tim Starling (talk | contribs)   03:08, 9 August 2010

Neither issue was introduced in this revision. They should be directed to whoever wrote the relevant code, or someone who cares about Oracle support.

Status & tagging log