Wikinaut has submitted this change and it was merged.

Change subject: Add uoi_user_registration for PostgreSQL
......................................................................


Add uoi_user_registration for PostgreSQL

* bump version 3.43 20131103
* added uoi_user_registration field to the user_openid table
* provide separate schema update functions for MySQL and PostgreSQL,
  bail explicitly on other databases
* use database-specific timestamp conversion

Bug: 34844
Bug: 34846
Change-Id: I0c102e270e261c5da89247c6f43ee3b2bf3bb10d
---
M CHANGES
M OpenID.hooks.php
M OpenID.php
M README
M SpecialOpenID.body.php
M TODO
M patches/openid_table.pg.sql
7 files changed, 43 insertions(+), 6 deletions(-)

Approvals:
  Wikinaut: Verified; Looks good to me, approved
  jenkins-bot: Checked



diff --git a/CHANGES b/CHANGES
index a71999b..b2b0d5e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,12 @@
 CHANGES
 =======
 
+3.43  20131103  bug 34844 and 34846
+                add uoi_user_registration for PostgreSQL
+                add uoi_user_registration field to the user_openid table
+                separate schema update functions for MySQL and PostgreSQL
+                bail explicitly on other databases
+                database-specific timestamp
 3.42  20131004  fixed a problem with label text on the preferences tab.
                 inverted internal hide/show OpenID property name,
                 but kept the default meaning "show OpenID on user pages"
diff --git a/OpenID.hooks.php b/OpenID.hooks.php
index 87cb650..8341680 100644
--- a/OpenID.hooks.php
+++ b/OpenID.hooks.php
@@ -471,6 +471,21 @@
         * @return bool
         */
        public static function onLoadExtensionSchemaUpdates( $updater = null ) {
+               switch ( $updater->getDB()->getType() ) {
+               case "mysql":
+                       return self::MySQLSchemaUpdates( $updater );
+               case "postgres":
+                       return self::PostgreSQLSchemaUpdates( $updater );
+               default:
+                       throw new MWException("OpenID does not support 
{$updater->getDB()->getType()} yet.");
+               }
+       }
+
+       /**
+        * @param $updater MysqlUpdater
+        * @return bool
+        */
+       public static function MySQLSchemaUpdates( $updater = null ) {
                // >= 1.17 support
                $updater->addExtensionTable( 'user_openid',
                        dirname( __FILE__ ) . '/patches/openid_table.sql' );
@@ -495,6 +510,22 @@
        }
 
        /**
+        * @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 true;
+       }
+
+       /**
         * @return string
         */
        private static function getOpenIDSmallLogoUrl() {
diff --git a/OpenID.php b/OpenID.php
index f6a9a08..f67fcce 100644
--- a/OpenID.php
+++ b/OpenID.php
@@ -29,7 +29,7 @@
        exit( 1 );
 }
 
-define( 'MEDIAWIKI_OPENID_VERSION', '3.42 20131004' );
+define( 'MEDIAWIKI_OPENID_VERSION', '3.43 20131103' );
 
 $path = dirname( __FILE__ );
 set_include_path( implode( PATH_SEPARATOR, array( $path ) ) . PATH_SEPARATOR . 
get_include_path() );
@@ -417,7 +417,6 @@
 $wgHooks['ArticleViewHeader'][] = 'OpenIDHooks::onArticleViewHeader';
 $wgHooks['SpecialPage_initList'][] = 'OpenIDHooks::onSpecialPage_initList';
 $wgHooks['LoadExtensionSchemaUpdates'][] = 
'OpenIDHooks::onLoadExtensionSchemaUpdates';
-
 $wgHooks['DeleteAccount'][] = 'OpenIDHooks::onDeleteAccount';
 $wgHooks['MergeAccountFromTo'][] = 'OpenIDHooks::onMergeAccountFromTo';
 
diff --git a/README b/README
index 6519555..6081f53 100644
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
 MediaWiki OpenID extension README
-version 3.41 20131003
+version 3.43 20131103
 
 Homepage and manual
 http://www.mediawiki.org/wiki/Extension:OpenID
diff --git a/SpecialOpenID.body.php b/SpecialOpenID.body.php
index 3ab236d..2c49437 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()
                        ),
                        __METHOD__
                );
diff --git a/TODO b/TODO
index 983529b..3687822 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,5 @@
 TO-DO LIST
-Status: 3.30 20130505
+Status: 3.43 20131103
 
 Bugs and suggestions should not be listed here but should be filed in the
 bugzilla bugtracker http://preview.tinyurl.com/openid-bugs
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: merged
Gerrit-Change-Id: I0c102e270e261c5da89247c6f43ee3b2bf3bb10d
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/extensions/OpenID
Gerrit-Branch: master
Gerrit-Owner: saper <[email protected]>
Gerrit-Reviewer: CSteipp <[email protected]>
Gerrit-Reviewer: Erjiang <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: Wikinaut <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-Reviewer: saper <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to