Index: trunk/phase3/includes/db/DatabaseMysql.php |
— | — | @@ -74,7 +74,7 @@ |
75 | 75 | } |
76 | 76 | if ($this->mConn === false) { |
77 | 77 | #$iplus = $i + 1; |
78 | | - #wfLogDBError("Connect loop error $iplus of $max ($server): " . mysql_errno() . " - " . mysql_error()."\n"); |
| 78 | + #wfLogDBError("Connect loop error $iplus of $max ($server): " . mysql_errno() . " - " . mysql_error()."\n"); |
79 | 79 | } |
80 | 80 | } |
81 | 81 | $phpError = $this->restoreErrorHandler(); |
— | — | @@ -90,7 +90,7 @@ |
91 | 91 | substr( $password, 0, 3 ) . "..., error: " . mysql_error() . "\n" ); |
92 | 92 | $success = false; |
93 | 93 | } |
94 | | - |
| 94 | + |
95 | 95 | wfProfileOut("dbconnect-$server"); |
96 | 96 | |
97 | 97 | if ( $dbName != '' && $this->mConn !== false ) { |
— | — | @@ -233,7 +233,7 @@ |
234 | 234 | } |
235 | 235 | |
236 | 236 | function affectedRows() { return mysql_affected_rows( $this->mConn ); } |
237 | | - |
| 237 | + |
238 | 238 | /** |
239 | 239 | * Estimate rows in dataset |
240 | 240 | * Returns estimated count, based on EXPLAIN output |
— | — | @@ -255,7 +255,7 @@ |
256 | 256 | } |
257 | 257 | |
258 | 258 | $this->freeResult($res); |
259 | | - return $rows; |
| 259 | + return $rows; |
260 | 260 | } |
261 | 261 | |
262 | 262 | function fieldInfo( $table, $field ) { |
— | — | @@ -277,28 +277,26 @@ |
278 | 278 | } |
279 | 279 | |
280 | 280 | function strencode( $s ) { |
281 | | - return mysql_real_escape_string( $s, $this->mConn ); |
| 281 | + $sQuoted = mysql_real_escape_string( $s, $this->mConn ); |
| 282 | + |
| 283 | + if($sQuoted === false) { |
| 284 | + $this->ping(); |
| 285 | + $sQuoted = mysql_real_escape_string( $s, $this->mConn ); |
| 286 | + } |
| 287 | + return $sQuoted; |
282 | 288 | } |
283 | 289 | |
284 | 290 | function ping() { |
285 | | - if( !function_exists( 'mysql_ping' ) ) { |
286 | | - wfDebug( "Tried to call mysql_ping but this is ancient PHP version. Faking it!\n" ); |
287 | | - return true; |
288 | | - } |
289 | 291 | $ping = mysql_ping( $this->mConn ); |
290 | 292 | if ( $ping ) { |
291 | 293 | return true; |
292 | 294 | } |
293 | 295 | |
294 | | - // Need to reconnect manually in MySQL client 5.0.13+ |
295 | | - if ( version_compare( mysql_get_client_info(), '5.0.13', '>=' ) ) { |
296 | | - mysql_close( $this->mConn ); |
297 | | - $this->mOpened = false; |
298 | | - $this->mConn = false; |
299 | | - $this->open( $this->mServer, $this->mUser, $this->mPassword, $this->mDBname ); |
300 | | - return true; |
301 | | - } |
302 | | - return false; |
| 296 | + mysql_close( $this->mConn ); |
| 297 | + $this->mOpened = false; |
| 298 | + $this->mConn = false; |
| 299 | + $this->open( $this->mServer, $this->mUser, $this->mPassword, $this->mDBname ); |
| 300 | + return true; |
303 | 301 | } |
304 | 302 | |
305 | 303 | function getServerVersion() { |
— | — | @@ -351,8 +349,8 @@ |
352 | 350 | $items = array(); |
353 | 351 | |
354 | 352 | foreach( $write as $table ) { |
355 | | - $tbl = $this->tableName( $table ) . |
356 | | - ( $lowPriority ? ' LOW_PRIORITY' : '' ) . |
| 353 | + $tbl = $this->tableName( $table ) . |
| 354 | + ( $lowPriority ? ' LOW_PRIORITY' : '' ) . |
357 | 355 | ' WRITE'; |
358 | 356 | $items[] = $tbl; |
359 | 357 | } |
— | — | @@ -382,7 +380,7 @@ |
383 | 381 | $this->query( "SET sql_big_selects=$encValue", __METHOD__ ); |
384 | 382 | } |
385 | 383 | |
386 | | - |
| 384 | + |
387 | 385 | /** |
388 | 386 | * Determines if the last failure was due to a deadlock |
389 | 387 | */ |
— | — | @@ -391,7 +389,7 @@ |
392 | 390 | } |
393 | 391 | |
394 | 392 | /** |
395 | | - * Determines if the last query error was something that should be dealt |
| 393 | + * Determines if the last query error was something that should be dealt |
396 | 394 | * with by pinging the connection and reissuing the query |
397 | 395 | */ |
398 | 396 | function wasErrorReissuable() { |
— | — | @@ -402,7 +400,7 @@ |
403 | 401 | * Determines if the last failure was due to the database being read-only. |
404 | 402 | */ |
405 | 403 | function wasReadOnlyError() { |
406 | | - return $this->lastErrno() == 1223 || |
| 404 | + return $this->lastErrno() == 1223 || |
407 | 405 | ( $this->lastErrno() == 1290 && strpos( $this->lastError(), '--read-only' ) !== false ); |
408 | 406 | } |
409 | 407 | |
— | — | @@ -420,7 +418,7 @@ |
421 | 419 | $res = $this->query( "SHOW CREATE TABLE $oldName" ); |
422 | 420 | $row = $this->fetchRow( $res ); |
423 | 421 | $oldQuery = $row[1]; |
424 | | - $query = preg_replace( '/CREATE TABLE `(.*?)`/', |
| 422 | + $query = preg_replace( '/CREATE TABLE `(.*?)`/', |
425 | 423 | "CREATE $tmp TABLE `$newName`", $oldQuery ); |
426 | 424 | if ($oldQuery === $query) { |
427 | 425 | # Couldn't do replacement |