r96557 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96556‎ | r96557 | r96558 >
Date:12:38, 8 September 2011
Author:reedy
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/REL1_17/phase3/includes/db/DatabaseOracle.php (modified) (history)
  • /branches/REL1_17/phase3/includes/filerepo/ForeignDBRepo.php (modified) (history)
  • /branches/REL1_17/phase3/includes/resourceloader/ResourceLoader.php (modified) (history)
  • /branches/REL1_17/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php (modified) (history)
  • /branches/REL1_17/phase3/includes/resourceloader/ResourceLoaderUserOptionsModule.php (modified) (history)

Diff [purge]

Index: branches/REL1_17/phase3/includes/db/DatabaseOracle.php
@@ -791,6 +791,7 @@
792792 $this->delete( $table, $deleteConds, $fname );
793793 }
794794
 795+
795796 if ( $sequenceData !== false && !isset( $row[$sequenceData['column']] ) ) {
796797 $row[$sequenceData['column']] = $this->nextSequenceValue( $sequenceData['sequence'] );
797798 }
@@ -1157,28 +1158,41 @@
11581159 return $s;
11591160 }
11601161
1161 - function selectRow( $table, $vars, $conds, $fname = 'DatabaseOracle::selectRow', $options = array(), $join_conds = array() ) {
 1162+ private function wrapFieldForWhere( $table, &$col, &$val ) {
11621163 global $wgContLang;
 1164+
 1165+ $col_info = $this->fieldInfoMulti( $table, $col );
 1166+ $col_type = $col_info != false ? $col_info->type() : 'CONSTANT';
 1167+ if ( $col_type == 'CLOB' ) {
 1168+ $col = 'TO_CHAR(' . $col . ')';
 1169+ $val = $wgContLang->checkTitleEncoding( $val );
 1170+ } elseif ( $col_type == 'VARCHAR2' && !mb_check_encoding( $val ) ) {
 1171+ $val = $wgContLang->checkTitleEncoding( $val );
 1172+ }
 1173+ }
11631174
1164 - if ($conds != null) {
1165 - $conds2 = array();
1166 - $conds = ( !is_array( $conds ) ) ? array( $conds ) : $conds;
1167 - foreach ( $conds as $col => $val ) {
1168 - $col_info = $this->fieldInfoMulti( $table, $col );
1169 - $col_type = $col_info != false ? $col_info->type() : 'CONSTANT';
1170 - if ( $col_type == 'CLOB' ) {
1171 - $conds2['TO_CHAR(' . $col . ')'] = $wgContLang->checkTitleEncoding( $val );
1172 - } elseif ( $col_type == 'VARCHAR2' && !mb_check_encoding( $val ) ) {
1173 - $conds2[$col] = $wgContLang->checkTitleEncoding( $val );
 1175+ private function wrapConditionsForWhere ( $table, $conds, $parentCol = null ) {
 1176+ $conds2 = array();
 1177+ foreach ( $conds as $col => $val ) {
 1178+ if ( is_array( $val ) ) {
 1179+ $conds2[$col] = $this->wrapConditionsForWhere ( $table, $val, $col );
 1180+ } else {
 1181+ if ( is_numeric( $col ) && $parentCol != null ) {
 1182+ $this->wrapFieldForWhere ( $table, $parentCol, $val );
11741183 } else {
1175 - $conds2[$col] = $val;
 1184+ $this->wrapFieldForWhere ( $table, $col, $val );
11761185 }
 1186+ $conds2[$col] = $val;
11771187 }
 1188+ }
 1189+ return $conds2;
 1190+ }
11781191
1179 - return parent::selectRow( $table, $vars, $conds2, $fname, $options, $join_conds );
1180 - } else {
1181 - return parent::selectRow( $table, $vars, $conds, $fname, $options, $join_conds );
 1192+ function selectRow( $table, $vars, $conds, $fname = 'DatabaseOracle::selectRow', $options = array(), $join_conds = array() ) {
 1193+ if ( is_array($conds) ) {
 1194+ $conds = $this->wrapConditionsForWhere( $table, $conds );
11821195 }
 1196+ return parent::selectRow( $table, $vars, $conds, $fname, $options, $join_conds );
11831197 }
11841198
11851199 /**
@@ -1225,32 +1239,10 @@
12261240 }
12271241
12281242 public function delete( $table, $conds, $fname = 'DatabaseOracle::delete' ) {
1229 - global $wgContLang;
1230 -
1231 - if ( $wgContLang != null && $conds != null && $conds != '*' ) {
1232 - $conds2 = array();
1233 - $conds = ( !is_array( $conds ) ) ? array( $conds ) : $conds;
1234 - foreach ( $conds as $col => $val ) {
1235 - $col_info = $this->fieldInfoMulti( $table, $col );
1236 - $col_type = $col_info != false ? $col_info->type() : 'CONSTANT';
1237 - if ( $col_type == 'CLOB' ) {
1238 - $conds2['TO_CHAR(' . $col . ')'] = $wgContLang->checkTitleEncoding( $val );
1239 - } else {
1240 - if ( is_array( $val ) ) {
1241 - $conds2[$col] = $val;
1242 - foreach ( $conds2[$col] as &$val2 ) {
1243 - $val2 = $wgContLang->checkTitleEncoding( $val2 );
1244 - }
1245 - } else {
1246 - $conds2[$col] = $wgContLang->checkTitleEncoding( $val );
1247 - }
1248 - }
1249 - }
1250 -
1251 - return parent::delete( $table, $conds2, $fname );
1252 - } else {
1253 - return parent::delete( $table, $conds, $fname );
 1243+ if ( is_array($conds) ) {
 1244+ $conds = $this->wrapConditionsForWhere( $table, $conds );
12541245 }
 1246+ return parent::delete( $table, $conds, $fname );
12551247 }
12561248
12571249 function update( $table, $values, $conds, $fname = 'DatabaseOracle::update', $options = array() ) {
@@ -1273,6 +1265,7 @@
12741266 }
12751267
12761268 if ( $conds != '*' ) {
 1269+ $conds = $this->wrapConditionsForWhere( $table, $conds );
12771270 $sql .= ' WHERE ' . $this->makeList( $conds, LIST_AND );
12781271 }
12791272
Index: branches/REL1_17/phase3/includes/filerepo/ForeignDBRepo.php
@@ -37,7 +37,7 @@
3838 if ( !isset( $this->dbConn ) ) {
3939 $this->dbConn = DatabaseBase::newFromType( $this->dbType,
4040 array(
41 - 'server' => $this->dbServer,
 41+ 'host' => $this->dbServer,
4242 'user' => $this->dbUser,
4343 'password' => $this->dbPassword,
4444 'dbname' => $this->dbName,
Property changes on: branches/REL1_17/phase3/includes/filerepo/ForeignDBRepo.php
___________________________________________________________________
Modified: svn:mergeinfo
4545 Merged /trunk/phase3/includes/filerepo/ForeignDBRepo.php:r80167,81689,87498,89253
Index: branches/REL1_17/phase3/includes/resourceloader/ResourceLoader.php
@@ -96,7 +96,8 @@
9797 ), __METHOD__
9898 );
9999 foreach ( $res as $row ) {
100 - $this->getModule( $row->mr_resource )->setMsgBlobMtime( $lang, $row->mr_timestamp );
 100+ $this->getModule( $row->mr_resource )->setMsgBlobMtime( $lang,
 101+ wfTimestamp( TS_UNIX, $row->mr_timestamp ) );
101102 unset( $modulesWithoutMessages[$row->mr_resource] );
102103 }
103104 }
Property changes on: branches/REL1_17/phase3/includes/resourceloader/ResourceLoader.php
___________________________________________________________________
Modified: svn:mergeinfo
104105 Merged /trunk/phase3/includes/resourceloader/ResourceLoader.php:r80167,81689,87498,89253
Index: branches/REL1_17/phase3/includes/resourceloader/ResourceLoaderUserOptionsModule.php
@@ -40,7 +40,7 @@
4141 global $wgUser;
4242
4343 if ( $context->getUser() === $wgUser->getName() ) {
44 - return $this->modifiedTime[$hash] = $wgUser->getTouched();
 44+ return $this->modifiedTime[$hash] = wfTimestamp( TS_UNIX, $wgUser->getTouched() );
4545 } else {
4646 return 1;
4747 }
Index: branches/REL1_17/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php
@@ -119,7 +119,10 @@
120120 }
121121 // Automatically register module
122122 else {
123 - $mtime = max( $module->getModifiedTime( $context ), wfTimestamp( TS_UNIX, $wgCacheEpoch ) );
 123+ // getModifiedTime() is supposed to return a UNIX timestamp, but it doesn't always
 124+ // seem to do that, and custom implementations might forget. Coerce it to TS_UNIX
 125+ $moduleMtime = wfTimestamp( TS_UNIX, $module->getModifiedTime( $context ) );
 126+ $mtime = max( $moduleMtime, wfTimestamp( TS_UNIX, $wgCacheEpoch ) );
124127 // Modules without dependencies or a group pass two arguments (name, timestamp) to
125128 // mediaWiki.loader.register()
126129 if ( !count( $module->getDependencies() && $module->getGroup() === null ) ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r80167Coerce mtimes to TS_UNIX before outputting them, and fix a wrong timestamp fo...catrope14:42, 13 January 2011
r81689Fix bug from r73645: setMsgBlobMtime() requires its timestamp parameter to be...tstarling05:33, 8 February 2011
r87498Fixes ForeignDBRepo SQL server connection. Fixes bug #28836.valhallasw15:04, 5 May 2011
r89253* unified where clause parameter wrapping for delete, update and selectRow...freakolowsky11:38, 1 June 2011

Status & tagging log