saper has uploaded a new change for review.
https://gerrit.wikimedia.org/r/92466
Change subject: Add uoi_user_registration for PostgreSQL
......................................................................
Add uoi_user_registration for PostgreSQL
* Define separate hooks for MySQL and PostgreSQL,
bail explicitly on other databases.
* Use database-specific timestamp conversion
Bug: 34844
Bug: 34846
Change-Id: I0c102e270e261c5da89247c6f43ee3b2bf3bb10d
---
M OpenID.hooks.php
M OpenID.php
M SpecialOpenID.body.php
M patches/openid_table.pg.sql
4 files changed, 25 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OpenID
refs/changes/66/92466/1
diff --git a/OpenID.hooks.php b/OpenID.hooks.php
index 87cb650..381fb2f 100644
--- a/OpenID.hooks.php
+++ b/OpenID.hooks.php
@@ -470,7 +470,7 @@
* @param $updater DatabaseUpdater
* @return bool
*/
- public static function onLoadExtensionSchemaUpdates( $updater = null ) {
+ public static function MySQLSchemaUpdates( $updater = null ) {
// >= 1.17 support
$updater->addExtensionTable( 'user_openid',
dirname( __FILE__ ) . '/patches/openid_table.sql' );
@@ -495,6 +495,20 @@
}
/**
+ * @param $updater PostgresUpdater
+ * @return bool
+ */
+ public static function PostgreSQLSchemaUpdates( $updater = null ) {
+ $base = dirname( __FILE__ ) . '/patches';
+ foreach ( array (
+ array( 'addTable', 'user_openid', $base .
'/openid_table.pg.sql', true ),
+ array( 'addPgField', 'user_openid',
'uoi_user_registration', 'TIMESTAMPTZ'),
+ ) as $update ) {
+ $updater->addExtensionUpdate( $update );
+ }
+ }
+
+ /**
* @return string
*/
private static function getOpenIDSmallLogoUrl() {
diff --git a/OpenID.php b/OpenID.php
index f6a9a08..366ae11 100644
--- a/OpenID.php
+++ b/OpenID.php
@@ -416,7 +416,13 @@
$wgHooks['BeforePageDisplay'][] = 'OpenIDHooks::onBeforePageDisplay';
$wgHooks['ArticleViewHeader'][] = 'OpenIDHooks::onArticleViewHeader';
$wgHooks['SpecialPage_initList'][] = 'OpenIDHooks::onSpecialPage_initList';
-$wgHooks['LoadExtensionSchemaUpdates'][] =
'OpenIDHooks::onLoadExtensionSchemaUpdates';
+if ( $wgDBtype === 'mysql' ) {
+ $wgHooks['LoadExtensionSchemaUpdates'][] =
'OpenIDHooks::MySQLSchemaUpdates';
+} elseif ($wgDBtype === 'postgres' ) {
+ $wgHooks['LoadExtensionSchemaUpdates'][] =
'OpenIDHooks::PostgreSQLSchemaUpdates';
+} else {
+ throw new MWException("OpenID does not support {$wgDBtype} yet.");
+}
$wgHooks['DeleteAccount'][] = 'OpenIDHooks::onDeleteAccount';
$wgHooks['MergeAccountFromTo'][] = 'OpenIDHooks::onMergeAccountFromTo';
diff --git a/SpecialOpenID.body.php b/SpecialOpenID.body.php
index 3ab236d..3922978 100644
--- a/SpecialOpenID.body.php
+++ b/SpecialOpenID.body.php
@@ -475,7 +475,7 @@
array(
'uoi_user' => $user->getId(),
'uoi_openid' => $url,
- 'uoi_user_registration' => wfTimestamp( TS_MW )
+ 'uoi_user_registration' => $dbw->timestamp(
wfTimestamp( TS_MW ) )
),
__METHOD__
);
diff --git a/patches/openid_table.pg.sql b/patches/openid_table.pg.sql
index 0b59b54..7e6c600 100644
--- a/patches/openid_table.pg.sql
+++ b/patches/openid_table.pg.sql
@@ -3,7 +3,8 @@
CREATE TABLE /*_*/user_openid (
uoi_openid VARCHAR(255) NOT NULL PRIMARY KEY,
- uoi_user INTEGER NOT NULL REFERENCES mwuser(user_id)
+ uoi_user INTEGER NOT NULL REFERENCES mwuser(user_id),
+ uoi_user_registration TIMESTAMPTZ
);
CREATE INDEX /*i*/user_openid_user ON /*_*/user_openid(uoi_user);
--
To view, visit https://gerrit.wikimedia.org/r/92466
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0c102e270e261c5da89247c6f43ee3b2bf3bb10d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OpenID
Gerrit-Branch: master
Gerrit-Owner: saper <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits