Index: trunk/phase3/maintenance/tests/SearchUpdateTest.php |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | |
4 | 4 | class DatabaseMock extends DatabaseBase { |
5 | 5 | function __construct( $server = false, $user = false, $password = false, $dbName = false, |
6 | | - $failFunction = false, $flags = 0, $tablePrefix = 'get from global' ) |
| 6 | + $flags = 0, $tablePrefix = 'get from global' ) |
7 | 7 | { |
8 | 8 | $this->mConn = true; |
9 | 9 | $this->mOpened = true; |
Index: trunk/phase3/includes/db/DatabaseOracle.php |
— | — | @@ -185,10 +185,10 @@ |
186 | 186 | var $mFieldInfoCache = array(); |
187 | 187 | |
188 | 188 | function __construct( $server = false, $user = false, $password = false, $dbName = false, |
189 | | - $failFunction = false, $flags = 0, $tablePrefix = 'get from global' ) |
| 189 | + $flags = 0, $tablePrefix = 'get from global' ) |
190 | 190 | { |
191 | 191 | $tablePrefix = $tablePrefix == 'get from global' ? $tablePrefix : strtoupper( $tablePrefix ); |
192 | | - parent::__construct( $server, $user, $password, $dbName, $failFunction, $flags, $tablePrefix ); |
| 192 | + parent::__construct( $server, $user, $password, $dbName, $flags, $tablePrefix ); |
193 | 193 | wfRunHooks( 'DatabaseOraclePostInit', array( &$this ) ); |
194 | 194 | } |
195 | 195 | |
— | — | @@ -218,14 +218,12 @@ |
219 | 219 | return true; |
220 | 220 | } |
221 | 221 | |
222 | | - static function newFromParams( $server, $user, $password, $dbName, $failFunction = false, $flags = 0 ) |
223 | | - { |
224 | | - return new DatabaseOracle( $server, $user, $password, $dbName, $failFunction, $flags ); |
| 222 | + static function newFromParams( $server, $user, $password, $dbName, $flags = 0 ){ |
| 223 | + return new DatabaseOracle( $server, $user, $password, $dbName, $flags ); |
225 | 224 | } |
226 | 225 | |
227 | 226 | /** |
228 | 227 | * Usually aborts on failure |
229 | | - * If the failFunction is set to a non-zero integer, returns success |
230 | 228 | */ |
231 | 229 | function open( $server, $user, $password, $dbName ) { |
232 | 230 | if ( !function_exists( 'oci_connect' ) ) { |
Index: trunk/phase3/includes/db/DatabasePostgres.php |
— | — | @@ -97,13 +97,10 @@ |
98 | 98 | var $mAffectedRows = null; |
99 | 99 | |
100 | 100 | function DatabasePostgres($server = false, $user = false, $password = false, $dbName = false, |
101 | | - $failFunction = false, $flags = 0 ) |
| 101 | + $flags = 0 ) |
102 | 102 | { |
103 | | - |
104 | | - $this->mFailFunction = $failFunction; |
105 | 103 | $this->mFlags = $flags; |
106 | 104 | $this->open( $server, $user, $password, $dbName); |
107 | | - |
108 | 105 | } |
109 | 106 | |
110 | 107 | function getType() { |
— | — | @@ -141,14 +138,12 @@ |
142 | 139 | return $this->numRows($res = $this->doQuery($SQL)); |
143 | 140 | } |
144 | 141 | |
145 | | - static function newFromParams( $server, $user, $password, $dbName, $failFunction = false, $flags = 0) |
146 | | - { |
147 | | - return new DatabasePostgres( $server, $user, $password, $dbName, $failFunction, $flags ); |
| 142 | + static function newFromParams( $server, $user, $password, $dbName, $flags = 0) { |
| 143 | + return new DatabasePostgres( $server, $user, $password, $dbName, $flags ); |
148 | 144 | } |
149 | 145 | |
150 | 146 | /** |
151 | 147 | * Usually aborts on failure |
152 | | - * If the failFunction is set to a non-zero integer, returns success |
153 | 148 | */ |
154 | 149 | function open( $server, $user, $password, $dbName ) { |
155 | 150 | # Test for Postgres support, to avoid suppressed fatal error |
— | — | @@ -188,11 +183,7 @@ |
189 | 184 | wfDebug( "DB connection error\n" ); |
190 | 185 | wfDebug( "Server: $server, Database: $dbName, User: $user, Password: " . substr( $password, 0, 3 ) . "...\n" ); |
191 | 186 | wfDebug( $this->lastError()."\n" ); |
192 | | - if ( !$this->mFailFunction ) { |
193 | | - throw new DBConnectionError( $this, $phpError ); |
194 | | - } else { |
195 | | - return false; |
196 | | - } |
| 187 | + return false; |
197 | 188 | } |
198 | 189 | |
199 | 190 | $this->mOpened = true; |
Index: trunk/phase3/includes/db/DatabaseIbm_db2.php |
— | — | @@ -112,7 +112,6 @@ |
113 | 113 | protected $mServer, $mUser, $mPassword, $mConn = null, $mDBname; |
114 | 114 | protected $mOut, $mOpened = false; |
115 | 115 | |
116 | | - protected $mFailFunction; |
117 | 116 | protected $mTablePrefix; |
118 | 117 | protected $mFlags; |
119 | 118 | protected $mTrxLevel = 0; |
— | — | @@ -164,7 +163,6 @@ |
165 | 164 | * These can be safely inherited |
166 | 165 | * |
167 | 166 | * Getter/Setter: (18) |
168 | | - * failFunction |
169 | 167 | * bufferResults |
170 | 168 | * ignoreErrors |
171 | 169 | * trxLevel |
— | — | @@ -405,22 +403,19 @@ |
406 | 404 | * @param $user String: username |
407 | 405 | * @param $password String: password |
408 | 406 | * @param $dbName String: database name on the server |
409 | | - * @param $failFunction Callback (optional) |
410 | 407 | * @param $flags Integer: database behaviour flags (optional, unused) |
411 | 408 | * @param $schema String |
412 | 409 | */ |
413 | 410 | public function DatabaseIbm_db2($server = false, $user = false, $password = false, |
414 | | - $dbName = false, $failFunction = false, $flags = 0, |
| 411 | + $dbName = false, $flags = 0, |
415 | 412 | $schema = self::USE_GLOBAL ) |
416 | 413 | { |
417 | | - |
418 | 414 | global $wgOut, $wgDBmwschema; |
419 | 415 | # Can't get a reference if it hasn't been set yet |
420 | 416 | if ( !isset( $wgOut ) ) { |
421 | 417 | $wgOut = null; |
422 | 418 | } |
423 | 419 | $this->mOut =& $wgOut; |
424 | | - $this->mFailFunction = $failFunction; |
425 | 420 | $this->mFlags = DBO_TRX | $flags; |
426 | 421 | |
427 | 422 | if ( $schema == self::USE_GLOBAL ) { |
— | — | @@ -579,13 +574,11 @@ |
580 | 575 | * @param $user String: username |
581 | 576 | * @param $password String |
582 | 577 | * @param $dbName String: database name on the server |
583 | | - * @param $failFunction Callback (optional) |
584 | 578 | * @param $flags Integer: database behaviour flags (optional, unused) |
585 | 579 | * @return DatabaseIbm_db2 object |
586 | 580 | */ |
587 | | - static function newFromParams( $server, $user, $password, $dbName, $failFunction = false, $flags = 0) |
588 | | - { |
589 | | - return new DatabaseIbm_db2( $server, $user, $password, $dbName, $failFunction, $flags ); |
| 581 | + static function newFromParams( $server, $user, $password, $dbName, $flags = 0) { |
| 582 | + return new DatabaseIbm_db2( $server, $user, $password, $dbName, $flags ); |
590 | 583 | } |
591 | 584 | |
592 | 585 | /** |
Index: trunk/phase3/includes/db/Database.php |
— | — | @@ -32,7 +32,6 @@ |
33 | 33 | protected $mServer, $mUser, $mPassword, $mConn = null, $mDBname; |
34 | 34 | protected $mOpened = false; |
35 | 35 | |
36 | | - protected $mFailFunction; |
37 | 36 | protected $mTablePrefix; |
38 | 37 | protected $mFlags; |
39 | 38 | protected $mTrxLevel = 0; |
— | — | @@ -47,14 +46,6 @@ |
48 | 47 | # These optionally set a variable and return the previous state |
49 | 48 | |
50 | 49 | /** |
51 | | - * Fail function, takes a Database as a parameter |
52 | | - * Set to false for default, 1 for ignore errors |
53 | | - */ |
54 | | - function failFunction( $function = null ) { |
55 | | - return wfSetVar( $this->mFailFunction, $function ); |
56 | | - } |
57 | | - |
58 | | - /** |
59 | 50 | * Boolean, controls output of large amounts of debug information |
60 | 51 | */ |
61 | 52 | function debug( $debug = null ) { |
— | — | @@ -291,12 +282,11 @@ |
292 | 283 | * @param $user String: database user name |
293 | 284 | * @param $password String: database user password |
294 | 285 | * @param $dbName String: database name |
295 | | - * @param $failFunction |
296 | 286 | * @param $flags |
297 | 287 | * @param $tablePrefix String: database table prefixes. By default use the prefix gave in LocalSettings.php |
298 | 288 | */ |
299 | 289 | function __construct( $server = false, $user = false, $password = false, $dbName = false, |
300 | | - $failFunction = false, $flags = 0, $tablePrefix = 'get from global' ) { |
| 290 | + $flags = 0, $tablePrefix = 'get from global' ) { |
301 | 291 | |
302 | 292 | global $wgOut, $wgDBprefix, $wgCommandLineMode; |
303 | 293 | # Can't get a reference if it hasn't been set yet |
— | — | @@ -304,7 +294,6 @@ |
305 | 295 | $wgOut = null; |
306 | 296 | } |
307 | 297 | |
308 | | - $this->mFailFunction = $failFunction; |
309 | 298 | $this->mFlags = $flags; |
310 | 299 | |
311 | 300 | if ( $this->mFlags & DBO_DEFAULT ) { |
— | — | @@ -340,18 +329,16 @@ |
341 | 330 | * @param $user String: database user name |
342 | 331 | * @param $password String: database user password |
343 | 332 | * @param $dbName String: database name |
344 | | - * @param failFunction |
345 | 333 | * @param $flags |
346 | 334 | */ |
347 | | - static function newFromParams( $server, $user, $password, $dbName, $failFunction = false, $flags = 0 ) |
| 335 | + static function newFromParams( $server, $user, $password, $dbName, $flags = 0 ) |
348 | 336 | { |
349 | 337 | wfDeprecated( __METHOD__ ); |
350 | | - return new DatabaseMysql( $server, $user, $password, $dbName, $failFunction, $flags ); |
| 338 | + return new DatabaseMysql( $server, $user, $password, $dbName, $flags ); |
351 | 339 | } |
352 | 340 | |
353 | 341 | /** |
354 | 342 | * Usually aborts on failure |
355 | | - * If the failFunction is set to a non-zero integer, returns success |
356 | 343 | * @param $server String: database server host |
357 | 344 | * @param $user String: database user name |
358 | 345 | * @param $password String: database user password |
— | — | @@ -403,16 +390,7 @@ |
404 | 391 | $error = $myError; |
405 | 392 | } |
406 | 393 | |
407 | | - if ( $this->mFailFunction ) { |
408 | | - # Legacy error handling method |
409 | | - if ( !is_int( $this->mFailFunction ) ) { |
410 | | - $ff = $this->mFailFunction; |
411 | | - $ff( $this, $error ); |
412 | | - } |
413 | | - } else { |
414 | | - # New method |
415 | | - throw new DBConnectionError( $this, $error ); |
416 | | - } |
| 394 | + throw new DBConnectionError( $this, $error ); |
417 | 395 | } |
418 | 396 | |
419 | 397 | /** |
— | — | @@ -2547,7 +2525,7 @@ |
2548 | 2526 | } |
2549 | 2527 | |
2550 | 2528 | function getHTML() { |
2551 | | - global $wgLang, $wgMessageCache, $wgUseFileCache, $wgShowDBErrorBacktrace; |
| 2529 | + global $wgLang, $wgMessageCache, $wgUseFileCache, $wgShowDBErrorBacktrace, $wgContLang; |
2552 | 2530 | |
2553 | 2531 | $sorry = 'Sorry! This site is experiencing technical difficulties.'; |
2554 | 2532 | $again = 'Try waiting a few minutes and reloading.'; |
— | — | @@ -2582,6 +2560,13 @@ |
2583 | 2561 | $cache = $this->fileCachedPage(); |
2584 | 2562 | # Cached version on file system? |
2585 | 2563 | if( $cache !== null ) { |
| 2564 | + # Adding support for RTL languages |
| 2565 | + if ( $wgContLang !== null ) { |
| 2566 | + if ( $wgContLang->isRTL() ) { |
| 2567 | + $cache = str_replace( '<html>', '<html style="direction:rtl;">', $cache ); |
| 2568 | + } |
| 2569 | + } |
| 2570 | + |
2586 | 2571 | # Hack: extend the body for error messages |
2587 | 2572 | $cache = str_replace( array('</html>','</body>'), '', $cache ); |
2588 | 2573 | # Add cache notice... |
Index: trunk/phase3/includes/db/DatabaseMssql.php |
— | — | @@ -18,12 +18,10 @@ |
19 | 19 | var $mAffectedRows = NULL; |
20 | 20 | |
21 | 21 | function __construct( $server = false, $user = false, $password = false, $dbName = false, |
22 | | - $failFunction = false, $flags = 0 ) |
| 22 | + $flags = 0 ) |
23 | 23 | { |
24 | | - $this->mFailFunction = $failFunction; |
25 | 24 | $this->mFlags = $flags; |
26 | 25 | $this->open( $server, $user, $password, $dbName ); |
27 | | - |
28 | 26 | } |
29 | 27 | |
30 | 28 | function cascadingDeletes() { |
— | — | @@ -51,14 +49,12 @@ |
52 | 50 | return false; |
53 | 51 | } |
54 | 52 | |
55 | | - static function newFromParams( $server, $user, $password, $dbName, $failFunction = false, $flags = 0 ) |
56 | | - { |
57 | | - return new DatabaseMssql( $server, $user, $password, $dbName, $failFunction, $flags ); |
| 53 | + static function newFromParams( $server, $user, $password, $dbName, $flags = 0 ) { |
| 54 | + return new DatabaseMssql( $server, $user, $password, $dbName, $flags ); |
58 | 55 | } |
59 | 56 | |
60 | 57 | /** |
61 | 58 | * Usually aborts on failure |
62 | | - * If the failFunction is set to a non-zero integer, returns success |
63 | 59 | */ |
64 | 60 | function open( $server, $user, $password, $dbName ) { |
65 | 61 | # Test for driver support, to avoid suppressed fatal error |
Index: trunk/phase3/includes/db/DatabaseSqlite.php |
— | — | @@ -23,9 +23,8 @@ |
24 | 24 | * Constructor. |
25 | 25 | * Parameters $server, $user and $password are not used. |
26 | 26 | */ |
27 | | - function __construct( $server = false, $user = false, $password = false, $dbName = false, $failFunction = false, $flags = 0 ) { |
| 27 | + function __construct( $server = false, $user = false, $password = false, $dbName = false, $flags = 0 ) { |
28 | 28 | global $wgSharedDB; |
29 | | - $this->mFailFunction = $failFunction; |
30 | 29 | $this->mFlags = $flags; |
31 | 30 | $this->mName = $dbName; |
32 | 31 | |
— | — | @@ -53,8 +52,8 @@ |
54 | 53 | */ |
55 | 54 | function implicitGroupby() { return false; } |
56 | 55 | |
57 | | - static function newFromParams( $server, $user, $password, $dbName, $failFunction = false, $flags = 0 ) { |
58 | | - return new DatabaseSqlite( $server, $user, $password, $dbName, $failFunction, $flags ); |
| 56 | + static function newFromParams( $server, $user, $password, $dbName, $flags = 0 ) { |
| 57 | + return new DatabaseSqlite( $server, $user, $password, $dbName, $flags ); |
59 | 58 | } |
60 | 59 | |
61 | 60 | /** Open an SQLite database and return a resource handle to it |
— | — | @@ -90,12 +89,7 @@ |
91 | 90 | } |
92 | 91 | if ( $this->mConn === false ) { |
93 | 92 | wfDebug( "DB connection error: $err\n" ); |
94 | | - if ( !$this->mFailFunction ) { |
95 | | - throw new DBConnectionError( $this, $err ); |
96 | | - } else { |
97 | | - return false; |
98 | | - } |
99 | | - |
| 93 | + return false; |
100 | 94 | } |
101 | 95 | $this->mOpened = !!$this->mConn; |
102 | 96 | # set error codes only, don't raise exceptions |
Index: trunk/phase3/includes/db/LoadBalancer.php |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | */ |
16 | 16 | class LoadBalancer { |
17 | 17 | /* private */ var $mServers, $mConns, $mLoads, $mGroupLoads; |
18 | | - /* private */ var $mFailFunction, $mErrorConnection; |
| 18 | + /* private */ var $mErrorConnection; |
19 | 19 | /* private */ var $mReadIndex, $mAllowLagged; |
20 | 20 | /* private */ var $mWaitForPos, $mWaitTimeout; |
21 | 21 | /* private */ var $mLaggedSlaveMode, $mLastError = 'Unknown error'; |
— | — | @@ -24,7 +24,6 @@ |
25 | 25 | /** |
26 | 26 | * @param $params Array with keys: |
27 | 27 | * servers Required. Array of server info structures. |
28 | | - * failFunction Deprecated, use exceptions instead. |
29 | 28 | * masterWaitTimeout Replication lag wait timeout |
30 | 29 | * loadMonitor Name of a class used to fetch server lag and load. |
31 | 30 | */ |
— | — | @@ -35,11 +34,6 @@ |
36 | 35 | } |
37 | 36 | $this->mServers = $params['servers']; |
38 | 37 | |
39 | | - if ( isset( $params['failFunction'] ) ) { |
40 | | - $this->mFailFunction = $params['failFunction']; |
41 | | - } else { |
42 | | - $this->mFailFunction = false; |
43 | | - } |
44 | 38 | if ( isset( $params['waitTimeout'] ) ) { |
45 | 39 | $this->mWaitTimeout = $params['waitTimeout']; |
46 | 40 | } else { |
— | — | @@ -73,9 +67,9 @@ |
74 | 68 | } |
75 | 69 | } |
76 | 70 | |
77 | | - static function newFromParams( $servers, $failFunction = false, $waitTimeout = 10 ) |
| 71 | + static function newFromParams( $servers, $waitTimeout = 10 ) |
78 | 72 | { |
79 | | - return new LoadBalancer( $servers, $failFunction, $waitTimeout ); |
| 73 | + return new LoadBalancer( $servers, $waitTimeout ); |
80 | 74 | } |
81 | 75 | |
82 | 76 | /** |
— | — | @@ -672,19 +666,11 @@ |
673 | 667 | // No last connection, probably due to all servers being too busy |
674 | 668 | wfLogDBError( "LB failure with no last connection\n" ); |
675 | 669 | $conn = new Database; |
676 | | - if ( $this->mFailFunction ) { |
677 | | - $conn->failFunction( $this->mFailFunction ); |
678 | | - $conn->reportConnectionError( $this->mLastError ); |
679 | | - } else { |
680 | | - // If all servers were busy, mLastError will contain something sensible |
681 | | - throw new DBConnectionError( $conn, $this->mLastError ); |
682 | | - } |
| 670 | + |
| 671 | + // If all servers were busy, mLastError will contain something sensible |
| 672 | + throw new DBConnectionError( $conn, $this->mLastError ); |
683 | 673 | } else { |
684 | | - if ( $this->mFailFunction ) { |
685 | | - $conn->failFunction( $this->mFailFunction ); |
686 | | - } else { |
687 | | - $conn->failFunction( false ); |
688 | | - } |
| 674 | + |
689 | 675 | $server = $conn->getProperty( 'mServer' ); |
690 | 676 | wfLogDBError( "Connection error: {$this->mLastError} ({$server})\n" ); |
691 | 677 | $conn->reportConnectionError( "{$this->mLastError} ({$server})" ); |