r97447 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97446‎ | r97447 | r97448 >
Date:23:55, 18 September 2011
Author:wikinaut
Status:deferred (Comments)
Tags:
Comment:
v0.937 added uoi_user_registration timestamp when a new OpenID identity is added. fixes bug30623
Modified paths:
  • /trunk/extensions/OpenID/OpenID.hooks.php (modified) (history)
  • /trunk/extensions/OpenID/OpenID.php (modified) (history)
  • /trunk/extensions/OpenID/README.OpenID-mediawiki-extension (modified) (history)
  • /trunk/extensions/OpenID/SpecialOpenID.body.php (modified) (history)
  • /trunk/extensions/OpenID/patches/openid_table.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenID/README.OpenID-mediawiki-extension
@@ -1,5 +1,5 @@
22 MediaWiki OpenID extension README.OpenID-mediawiki-extension file
3 -version 0.934-beta 20110829
 3+version 0.937-beta 20110019
44
55 Homepage and manual http://www.mediawiki.org/wiki/Extension:OpenID
66
@@ -462,7 +462,6 @@
463463 == TODO ==
464464
465465 * Code review http://preview.tinyurl.com/openid-codereview
466 -
467466 * Move TODO file and things below into Bugzilla
468467
469468 The TODO file in this distribution has stuff I think needs to be
@@ -477,6 +476,7 @@
478477 into that account now
479478
480479 == CHANGES ==
 480+* 0.937 added uoi_user_registration timestamp field (bug30623)
481481 * 0.934 fixes
482482 bug 29543 After logging in with OpenID, user page link in the personal toolbar
483483 pt portlet) still has the User:IP link (needs refresh to link to
Index: trunk/extensions/OpenID/OpenID.hooks.php
@@ -139,8 +139,17 @@
140140 $rows = '';
141141 foreach ( $urls as $url ) {
142142 $rows .= Xml::tags( 'tr', array(),
143 - Xml::tags( 'td', array(), Xml::element( 'a', array( 'href' => $url ), $url ) ) .
144 - Xml::tags( 'td', array(), $sk->link( $delTitle, wfMsgHtml( 'openid-urls-delete' ), array(), array( 'url' => $url ) ) )
 143+ Xml::tags( 'td',
 144+ array(),
 145+ Xml::element( 'a', array( 'href' => $url ), $url )
 146+ ) .
 147+ Xml::tags( 'td',
 148+ array(),
 149+ $sk->link( $delTitle, wfMsgHtml( 'openid-urls-delete' ),
 150+ array(),
 151+ array( 'url' => $url )
 152+ )
 153+ )
145154 ) . "\n";
146155 }
147156 $info = Xml::tags( 'table', array( 'class' => 'wikitable' ),
@@ -293,6 +302,7 @@
294303 if ( $wgDBtype == 'mysql' ) {
295304 $wgExtNewTables[] = array( 'user_openid', "$base/openid_table.sql" );
296305 $wgUpdates['mysql'][] = array( array( __CLASS__, 'makeUoiUserNotUnique' ) );
 306+ $wgUpdates['mysql'][] = array( array( __CLASS__, 'addUoiUserRegistration' ) );
297307 } elseif ( $wgDBtype == 'postgres' ) {
298308 $wgExtNewTables[] = array( 'user_openid', "$base/openid_table.pg.sql" );
299309 # This doesn't work since MediaWiki doesn't use $wgUpdates when
@@ -305,6 +315,7 @@
306316 $updater->addExtensionUpdate( array( 'addTable', 'user_openid', $dbPatch, true ) );
307317 if ( $updater->getDB()->getType() == 'mysql' ) {
308318 $updater->addExtensionUpdate( array( array( __CLASS__, 'makeUoiUserNotUnique' ) ) );
 319+ $updater->addExtensionUpdate( array( array( __CLASS__, 'addUoiUserRegistration' ) ) );
309320 }
310321 }
311322
@@ -322,14 +333,31 @@
323334
324335 $info = $db->fieldInfo( 'user_openid', 'uoi_user' );
325336 if ( !$info->isMultipleKey() ) {
326 - echo( "Making uoi_user filed not unique..." );
 337+ echo( "Making uoi_user field not unique..." );
327338 $db->sourceFile( dirname( __FILE__ ) . '/patches/patch-uoi_user-not-unique.sql' );
328339 echo( " done.\n" );
329340 } else {
330341 echo( "...uoi_user field is already not unique.\n" );
331342 }
332343 }
 344+ public static function addUoiUserRegistration( $updater = null ) {
 345+ if ( $updater === null ) {
 346+ $db = wfGetDB( DB_MASTER );
 347+ } else {
 348+ $db = $updater->getDB();
 349+ }
 350+ if ( !$db->tableExists( 'user_openid' ) )
 351+ return;
333352
 353+ if ( !$db->fieldExists( 'user_openid', 'uoi_user_registration' ) ) {
 354+ echo( "Adding uoi_user_registration field..." );
 355+ $db->sourceFile( dirname( __FILE__ ) . '/patches/patch-uoi_user_registration-not-present.sql' );
 356+ echo( " done.\n" );
 357+ } else {
 358+ echo( "...uoi_user_registration field present.\n" );
 359+ }
 360+ }
 361+
334362 private static function loginStyle() {
335363 global $wgOpenIDLoginLogoUrl;
336364 return <<<EOS
Index: trunk/extensions/OpenID/patches/openid_table.sql
@@ -4,7 +4,8 @@
55
66 CREATE TABLE /*_*/user_openid (
77 uoi_openid varchar(255) NOT NULL PRIMARY KEY,
8 - uoi_user int(5) unsigned NOT NULL
 8+ uoi_user int(5) unsigned NOT NULL,
 9+ uoi_user_registration binary(14)
910 ) /*$wgDBTableOptions*/;
1011
1112 CREATE INDEX /*i*/user_openid_user ON /*_*/user_openid(uoi_user);
Index: trunk/extensions/OpenID/SpecialOpenID.body.php
@@ -334,7 +334,7 @@
335335 $dbr = wfGetDB( DB_SLAVE );
336336 $res = $dbr->select(
337337 array( 'user_openid' ),
338 - array( 'uoi_openid' ),
 338+ array( 'uoi_openid', 'uoi_user_registration' ),
339339 array( 'uoi_user' => $user->getId() ),
340340 __METHOD__
341341 );
@@ -371,7 +371,8 @@
372372 'user_openid',
373373 array(
374374 'uoi_user' => $user->getId(),
375 - 'uoi_openid' => $url
 375+ 'uoi_openid' => $url,
 376+ 'uoi_user_registration' => wfTimestamp( TS_MW )
376377 ),
377378 __METHOD__
378379 );
Index: trunk/extensions/OpenID/OpenID.php
@@ -27,7 +27,7 @@
2828 exit( 1 );
2929 }
3030
31 -define( 'MEDIAWIKI_OPENID_VERSION', '0.936-beta 20110831' );
 31+define( 'MEDIAWIKI_OPENID_VERSION', '0.937-beta 20110919' );
3232
3333 $path = dirname( __FILE__ );
3434 set_include_path( implode( PATH_SEPARATOR, array( $path ) ) . PATH_SEPARATOR . get_include_path() );

Follow-up revisions

RevisionCommit summaryAuthorDate
r97566follow up to r97447 : show OpenID registration timestamps in OpenID preferenc...wikinaut22:18, 19 September 2011
r97770follow up to r97447 r97566 . changed function name getUserUrl to getUserOpenI...wikinaut23:18, 21 September 2011
r99511follow-up r97447 . removed redundant updater code which duplicated core logic...wikinaut18:03, 11 October 2011
r99529follow-up r99511 r97447 and not using dropIndex and addIndex directly any mor...wikinaut18:39, 11 October 2011

Comments

#Comment by 😂 (talk | contribs)   20:10, 5 October 2011

This updater is overly complicated and duplicates core logic. Just do

addUpdate( array( 'addField', 'table', 'field', 'patch' ) )
#Comment by Wikinaut (talk | contribs)   18:50, 10 October 2011

Please can you help and show me, what exactly should be changed? I tried to find some information, without success.

Perhaps, in this case, you as expert can better perform the requested changes (than I could do).

#Comment by 😂 (talk | contribs)   19:26, 10 October 2011

Look at the dozens of examples in MysqlUpdater (in core) or several extensions that already support the new installer.

#Comment by Wikinaut (talk | contribs)   19:27, 10 October 2011

is this addUpdate only for MySql ?

#Comment by Reedy (talk | contribs)   19:39, 10 October 2011

No

#Comment by 😂 (talk | contribs)   19:40, 10 October 2011

It's actually addExtensionUpdate, my mistake. And no, it's for all backends. Again, look at the source.

#Comment by Wikinaut (talk | contribs)   19:43, 10 October 2011

@ ^demon: I thought, my grep was broken ;-) Please can you also post a link to an extension, which can be seen and used as a good example ?

#Comment by Wikinaut (talk | contribs)   01:05, 11 October 2011

suggested and tested patch - pls. can you comment ? http://dpaste.com/631746/

It also requires: http://dpaste.com/631742/

#Comment by Wikinaut (talk | contribs)   18:04, 11 October 2011

fixed in follow-up 99511 . reset to new

Status & tagging log