Index: trunk/extensions/OpenID/OpenID.hooks.php |
— | — | @@ -278,26 +278,35 @@ |
279 | 279 | return true; |
280 | 280 | } |
281 | 281 | |
282 | | - public static function onLoadExtensionSchemaUpdates() { |
283 | | - global $wgDBtype, $wgUpdates, $wgExtNewTables; |
284 | | - |
| 282 | + public static function onLoadExtensionSchemaUpdates( $updater = null ) { |
285 | 283 | $base = dirname( __FILE__ ); |
286 | | - |
287 | | - if ( $wgDBtype == 'mysql' ) { |
288 | | - $wgExtNewTables[] = array( 'user_openid', "$base/openid_table.sql" ); |
289 | | - $wgUpdates['mysql'][] = array( array( __CLASS__, 'makeUoiUserNotUnique' ) ); |
290 | | - } else if ( $wgDBtype == 'postgres' ) { |
291 | | - $wgExtNewTables[] = array( 'user_openid', "$base/openid_table.pg.sql" ); |
292 | | - # This doesn't work since MediaWiki doesn't use $wgUpdates when |
293 | | - # updating a PostgreSQL database |
294 | | - #$wgUpdates['postgres'][] = array( array( __CLASS__, 'makeUoiUserNotUnique' ) ); |
| 284 | + if ( $updater === null ) { // < 1.17 |
| 285 | + global $wgDBtype, $wgUpdates, $wgExtNewTables; |
| 286 | + if ( $wgDBtype == 'mysql' ) { |
| 287 | + $wgExtNewTables[] = array( 'user_openid', "$base/openid_table.sql" ); |
| 288 | + $wgUpdates['mysql'][] = array( array( __CLASS__, 'makeUoiUserNotUnique' ) ); |
| 289 | + } else if ( $wgDBtype == 'postgres' ) { |
| 290 | + $wgExtNewTables[] = array( 'user_openid', "$base/openid_table.pg.sql" ); |
| 291 | + # This doesn't work since MediaWiki doesn't use $wgUpdates when |
| 292 | + # updating a PostgreSQL database |
| 293 | + #$wgUpdates['postgres'][] = array( array( __CLASS__, 'makeUoiUserNotUnique' ) ); |
| 294 | + } |
| 295 | + } else { |
| 296 | + $dbPatch = "$base/" . ( $updater->getDB()->getType() == 'postgres' ? |
| 297 | + 'openid_table.pg.sql' : 'openid_table.sql' ); |
| 298 | + $updater->addExtensionUpdate( array( 'addTable', 'user_openid', $dbPatch ) ); |
| 299 | + $updater->addExtensionUpdate( array( array( __CLASS__, 'makeUoiUserNotUnique' ) ) ); |
295 | 300 | } |
296 | 301 | |
297 | 302 | return true; |
298 | 303 | } |
299 | 304 | |
300 | | - public static function makeUoiUserNotUnique() { |
301 | | - $db = wfGetDB( DB_MASTER ); |
| 305 | + public static function makeUoiUserNotUnique( $updater = null ) { |
| 306 | + if ( $updater === null ) { |
| 307 | + $db = wfGetDB( DB_MASTER ); |
| 308 | + } else { |
| 309 | + $db = $updater->getDB(); |
| 310 | + } |
302 | 311 | if ( !$db->tableExists( 'user_openid' ) ) |
303 | 312 | return; |
304 | 313 | |