r89014 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89013‎ | r89014 | r89015 >
Date:02:30, 28 May 2011
Author:wikinaut
Status:deferred (Comments)
Tags:
Comment:
fixed bug 28993 - Make OpenID extension aware of user deletions done by extension UserMerge and Delete (and probably others). hooks on the new hooks DeleteAccount and on MergeAccountFromTo e.g. from action in UserMerge
Modified paths:
  • /trunk/extensions/OpenID/OpenID.hooks.php (modified) (history)
  • /trunk/extensions/OpenID/OpenID.i18n.php (modified) (history)
  • /trunk/extensions/OpenID/OpenID.setup.php (modified) (history)
  • /trunk/extensions/OpenID/OpenIDProvider.body.php (modified) (history)
  • /trunk/extensions/OpenID/README.OpenID-mediawiki-extension (modified) (history)
  • /trunk/extensions/OpenID/SpecialOpenIDLogin.body.php (modified) (history)
  • /trunk/extensions/OpenID/TODO (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenID/OpenID.setup.php
@@ -27,7 +27,7 @@
2828 exit( 1 );
2929 }
3030
31 -define( 'MEDIAWIKI_OPENID_VERSION', '0.928-beta' );
 31+define( 'MEDIAWIKI_OPENID_VERSION', '0.929-beta' );
3232
3333 $path = dirname( __FILE__ );
3434 set_include_path( implode( PATH_SEPARATOR, array( $path ) ) . PATH_SEPARATOR . get_include_path() );
@@ -208,6 +208,13 @@
209209 $wgOpenIDAllowServingOpenIDUserAccounts = true;
210210
211211 /**
 212+ * When merging accounts with the UserMerge and Delete extension,
 213+ * should OpenIDs associated to the "from" account automatically be associated
 214+ * to the "to" account ?
 215+ */
 216+$wgOpenIDMergeOnAccountMerge = false;
 217+
 218+/**
212219 * If true, will show provider icons instead of the text.
213220 */
214221 $wgOpenIDShowProviderIcons = false;
@@ -272,9 +279,11 @@
273280 $wgHooks['BeforePageDisplay'][] = 'OpenIDHooks::onBeforePageDisplay';
274281 $wgHooks['ArticleViewHeader'][] = 'OpenIDHooks::onArticleViewHeader';
275282 $wgHooks['SpecialPage_initList'][] = 'OpenIDHooks::onSpecialPage_initList';
276 -
277283 $wgHooks['LoadExtensionSchemaUpdates'][] = 'OpenIDHooks::onLoadExtensionSchemaUpdates';
278284
 285+$wgHooks['DeleteAccount'][] = 'OpenIDHooks::onDeleteAccount';
 286+$wgHooks['MergeAccountFromTo'][] = 'OpenIDHooks::onMergeAccountFromTo';
 287+
279288 # 1.16+
280289 $wgHooks['GetPreferences'][] = 'OpenIDHooks::onGetPreferences';
281290
Index: trunk/extensions/OpenID/TODO
@@ -1,4 +1,4 @@
2 -Status: 0.928-beta 20110525
 2+Status: 0.929-beta 20110528
33
44 ? more details are needed to understand the "to do"
55 * resolved, or partially resolved, wontfix
@@ -19,13 +19,8 @@
2020 $path=array( dirname( __FILE__ ) );
2121 set_include_path(implode(PATH_SEPARATOR,$path).PATH_SEPARATOR.get_include_path());
2222 in OpenID.setup.php. I don't know, if it can be avoided.
23 -- allow user to set a password in case of !$wgOpenIDClientOnly && $wgOpenIDOnly
24 - (https://bugzilla.wikimedia.org/show_bug.cgi?id=29027)
25 - = case Server/OpenID-Only
2623 - keep user from mailing new password in OpenID account except case S/OO
2724 - keep user from setting password in OpenID account except case S/OO
28 -- be aware of user deletions done by extension UserMerge and Delete (and others)
29 - https://bugzilla.wikimedia.org/show_bug.cgi?id=28993
3025 - participate in account-creation throttle
3126 - audit to prevent circumventing blocks/bans
3227 - share timezone when/if available
@@ -43,6 +38,12 @@
4439 * Configure some stuff through Special:Preferences or a dedicated control panel
4540 (under construction, see Special:OpenIDDashboard)
4641
 42++ be aware of user deletions done by extension UserMerge and Delete (and others)
 43+ https://bugzilla.wikimedia.org/show_bug.cgi?id=28993
 44++ allow user to set or reset a password in case of
 45+ !$wgOpenIDClientOnly && $wgOpenIDOnly
 46+ (https://bugzilla.wikimedia.org/show_bug.cgi?id=29027)
 47+ = case Server/OpenID-Only
4748 + Execute MediaWiki hook 'AddNewAccount' when new account is added
4849 https://bugzilla.wikimedia.org/show_bug.cgi?id=21711
4950 + Add a Storage class for $wgMemc
Index: trunk/extensions/OpenID/OpenIDProvider.body.php
@@ -46,7 +46,7 @@
4747 if ( $this->id == 'openid' ) {
4848 $url = isset( $_COOKIE[$wgCookiePrefix.'OpenID'] ) ? htmlspecialchars( $_COOKIE[$wgCookiePrefix.'OpenID'] ) : '';
4949 $html .= '<input type="text" name="openid_url" id="openid_url" size="45" value="' . $url . '" />';
50 - $html .= Xml::submitButton( wfMsg( 'login' ) );
 50+ $html .= Xml::submitButton( wfMsg( 'userlogin' ) );
5151 } else {
5252 $html .= '<input type="hidden" id="openid_provider_url_' . $this->id . '" value="' . $this->url . '" />';
5353 if ( strpos( $this->url, '{' ) === false ) {
@@ -54,7 +54,7 @@
5555 } else {
5656 $html .= '<input type="text" id="openid_provider_param_' . $this->id . '" size="25" value="" />';
5757 }
58 - $html .= Xml::submitButton( wfMsg( 'login' ) );
 58+ $html .= Xml::submitButton( wfMsg( 'userlogin' ) );
5959 }
6060 $html .= '</div>';
6161
Index: trunk/extensions/OpenID/OpenID.i18n.php
@@ -107,6 +107,7 @@
108108 You would not able to log in without an OpenID.',
109109 'openiddelete-sucess' => 'The OpenID has been successfully removed from your account.',
110110 'openiddelete-error' => 'An error occured while removing the OpenID from your account.',
 111+ 'openid-openids-were-not-merged' => 'OpenID(s) were not merged when merging the user accounts.',
111112
112113 'prefs-openid' => 'OpenID',
113114 'openid-prefstext' => '[http://openid.net/ OpenID] preferences',
@@ -184,6 +185,7 @@
185186 'openid-dashboard-title-admin' => 'Display name and page title for the adminstrator OpenID dashboard on Special:SpecialPages',
186187 'openid-dashboard-introduction' => 'Intro text for the special OpenID dashboard page: the user gets status information about the current OpenID settings of this wiki.
187188 * $1 is the url of the help page explaining the parameters',
 189+ 'openid-openids-were-not-merged' => 'When merging user accounts by UserMerge or similar extensions, OpenID(s) are not merged if $wgOpenIDMergeOnAccountMerge=false (default).',
188190 );
189191
190192 /** Faeag Rotuma (Faeag Rotuma)
Index: trunk/extensions/OpenID/README.OpenID-mediawiki-extension
@@ -360,6 +360,11 @@
361361 exists i.e. has content. The mere existence of a user account is (currently)
362362 not sufficient.
363363
 364+* $wgOpenIDMergeOnAccountMerge (default: false)
 365+ When merging accounts with the UserMerge and Delete extension,
 366+ should OpenIDs associated to the "from" account automatically be associated
 367+ to the "to" account ?
 368+
364369 * $wgOpenIDShowProviderIcons -- defaults to false due to potential
365370 brand issues. With this enabled, users will see button graphics
366371 instead of just links in OpenID provider UI.
Index: trunk/extensions/OpenID/OpenID.hooks.php
@@ -235,6 +235,59 @@
236236 }
237237
238238
 239+ public static function onDeleteAccount( $userObj ) {
 240+ global $wgOut;
 241+
 242+ if ( is_object( $userObj ) ) {
 243+
 244+ $username = $userObj->getName();
 245+ $userID = $userObj->getID();
 246+
 247+ $dbw = wfGetDB( DB_MASTER );
 248+
 249+ $dbw->delete( 'user_openid', array( 'uoi_user' => $userID ) );
 250+ $wgOut->addHTML( "OpenID " . wfMsg( 'usermerge-userdeleted', $username, $userID ) );
 251+
 252+ wfDebug( "OpenID: deleted OpenID user $username ($userID)\n" );
 253+
 254+ }
 255+
 256+ return true;
 257+
 258+ }
 259+
 260+ public static function onMergeAccountFromTo( $fromUserObj, $toUserObj ) {
 261+ global $wgOut,$wgOpenIDMergeOnAccountMerge;
 262+
 263+ if ( is_object( $fromUserObj ) && is_object( $toUserObj) ) {
 264+
 265+ $fromUsername = $fromUserObj->getName();
 266+ $fromUserID = $fromUserObj->getID();
 267+ $toUsername = $toUserObj->getName();
 268+ $toUserID = $toUserObj->getID();
 269+
 270+ if ( $wgOpenIDMergeOnAccountMerge ) {
 271+
 272+ $dbw = wfGetDB( DB_MASTER );
 273+
 274+ $dbw->update( 'user_openid', array( 'uoi_user' => $toUserID ), array( 'uoi_user' => $fromUserID ) );
 275+ $wgOut->addHTML( "OpenID " . wfMsg('usermerge-updating', 'user_openid', $fromUsername, $toUsername ) . "<br />\n" );
 276+
 277+ wfDebug( "OpenID: transferred OpenID(s) of $fromUsername ($fromUserID) => $toUsername ($toUserID)\n" );
 278+
 279+ } else {
 280+
 281+ $wgOut->addHTML( wfMsg( 'openid-openids-were-not-merged' ) . "<br />\n" );
 282+ wfDebug( "OpenID: OpenID(s) were not merged for merged users $fromUsername ($fromUserID) => $toUsername ($toUserID)\n" );
 283+
 284+ }
 285+
 286+ }
 287+
 288+ return true;
 289+
 290+ }
 291+
239292 # list of preferences used by extension
240293 private static $oidPrefs = array( 'hide' );
241294 private static $oidUpdateOnLogin = array( 'nickname', 'email', 'fullname',
Index: trunk/extensions/OpenID/SpecialOpenIDLogin.body.php
@@ -334,7 +334,7 @@
335335 Xml::openElement( 'tr' ) . "\n" .
336336 Xml::element( 'td', array(), '' ) . "\n" .
337337 Xml::tags( 'td', array( 'class' => 'mw-submit' ),
338 - Xml::submitButton( wfMsg( 'login' ), array( 'name' => 'wpOK' ) ) .
 338+ Xml::submitButton( wfMsg( 'userlogin' ), array( 'name' => 'wpOK' ) ) .
339339 Xml::submitButton( wfMsg( 'cancel' ), array( 'name' => 'wpCancel' ) )
340340 ) . "\n" .
341341 Xml::closeElement( 'tr' ) . "\n" .

Comments

#Comment by Nikerabbit (talk | contribs)   06:52, 28 May 2011

Instead of addHtml you could use addWikiMsg or wrapWikiMsg which automatically parse the contents.

#Comment by Wikinaut (talk | contribs)   14:21, 28 May 2011

In my local version I changed addHTML to wrapWikiMsg and applied the necessary changes, but this wraps all output text lines into

...

, which renders the output differently.

See https://bugzilla.wikimedia.org/show_bug.cgi?id=19226#c6 and comment in OutputPage.

Thus I decided to leave the code for the time being as it is - until the alleged parser bug is solved.

But thanks for pointing out.

#Comment by Wikinaut (talk | contribs)   14:25, 28 May 2011

it renders all output text lines into

<p> line1 </p>
<p> line2 </p>
<p> line3 </p>

If you show me how I can get

line1 <br/>
line2 <br/>
line3 <br/>

using the suggested calls that's what I am looking for.

RE: http://www.mediawiki.org/wiki/Localisation#Recommended_ways

Status & tagging log