r99361 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99360‎ | r99361 | r99362 >
Date:18:32, 9 October 2011
Author:kwisatz
Status:ok (Comments)
Tags:
Comment:
Follow up to r99355 and r99357: used TitleObject->getFullURL() and prefixed table field names; added message documentation
Modified paths:
  • /trunk/extensions/TwitterLogin/SpecialTwitterLogin.php (modified) (history)
  • /trunk/extensions/TwitterLogin/TwitterLogin.i18n.php (modified) (history)
  • /trunk/extensions/TwitterLogin/TwitterLogin.php (modified) (history)
  • /trunk/extensions/TwitterLogin/schema (added) (history)
  • /trunk/extensions/TwitterLogin/schema/twitter_user.patch.twitter_id.sql (added) (history)
  • /trunk/extensions/TwitterLogin/schema/twitter_user.patch.user_id.sql (added) (history)
  • /trunk/extensions/TwitterLogin/schema/twitter_user.sql (added) (history)
  • /trunk/extensions/TwitterLogin/twitter_user.sql (deleted) (history)

Diff [purge]

Index: trunk/extensions/TwitterLogin/twitter_user.sql
@@ -1,6 +0,0 @@
2 -CREATE TABLE IF NOT EXISTS `twitter_user` (
3 - `user_id` int(10) unsigned NOT NULL,
4 - `twitter_id` varchar(255) NOT NULL,
5 - PRIMARY KEY (`user_id`),
6 - UNIQUE KEY `twitter_id` (`twitter_id`)
7 -);
Index: trunk/extensions/TwitterLogin/TwitterLogin.i18n.php
@@ -22,3 +22,14 @@
2323 'twitterlogin-couldnotconnect' => 'Could not connect to Twitter. Refresh the page or try again later.'
2424 );
2525
 26+/** Message Documentation
 27+ * @author David Raison
 28+ */
 29+$messages['qqq'] = array(
 30+ 'twitterlogin' => 'Link of the special page',
 31+ 'twitterlogin-signup' => 'Explains users they can register and sign up to the wiki with their twitter account. Used on specialpage default.',
 32+ 'twiterlogin-tietoaccount' => 'Message displayed on the default specialpage when a logged in user visits it. (NOT in use)',
 33+ 'twitterlogin-desc' => 'Description of the extension, see setup file',
 34+ 'twitterlogin-alreadyloggedin' => 'Message displayed on the default specialpage. tietoaccount replacement.',
 35+ 'twitterlogin-couldnotconnect' => 'Tell the user the connection to twitter oauth server did not work.'
 36+);
Index: trunk/extensions/TwitterLogin/schema/twitter_user.patch.user_id.sql
@@ -0,0 +1 @@
 2+ALTER TABLE `twitter_user` CHANGE `user_id` `tl_user_id` int(10) unsigned;
Index: trunk/extensions/TwitterLogin/schema/twitter_user.patch.twitter_id.sql
@@ -0,0 +1 @@
 2+ALTER TABLE `twitter_user` CHANGE `twitter_id` `tl_twitter_id` varchar(255);
Index: trunk/extensions/TwitterLogin/schema/twitter_user.sql
@@ -0,0 +1,6 @@
 2+CREATE TABLE IF NOT EXISTS `twitter_user` (
 3+ `tl_user_id` int(10) unsigned NOT NULL,
 4+ `tl_twitter_id` varchar(255) NOT NULL,
 5+ PRIMARY KEY (`tl_user_id`),
 6+ UNIQUE KEY `tl_twitter_id` (`tl_twitter_id`)
 7+);
Index: trunk/extensions/TwitterLogin/TwitterLogin.php
@@ -48,8 +48,12 @@
4949 $wgHooks['UserLoadFromSession'][] = array($stl,'efTwitterAuth');
5050 $wgHooks['UserLogoutComplete'][] = array($stl,'efTwitterLogout');
5151
52 -function efSetupTwitterLoginSchema() {
 52+function efSetupTwitterLoginSchema( $updater ) {
5353 $updater->addExtensionUpdate( array( 'addTable', 'twitter_user',
54 - dirname(__FILE__) . '/twitter_user.sql', true ) );
 54+ dirname(__FILE__) . '/schema/twitter_user.sql', true ) );
 55+ $updater->addExtensionUpdate( array( 'modifyField', 'twitter_user','user_id',
 56+ dirname(__FILE__) . '/schema/twitter_user.patch.user_id.sql', true ) );
 57+ $updater->addExtensionUpdate( array( 'modifyField', 'twitter_user','twitter_id',
 58+ dirname(__FILE__) . '/schema/twitter_user.patch.twitter_id.sql', true ) );
5559 return true;
5660 }
Index: trunk/extensions/TwitterLogin/SpecialTwitterLogin.php
@@ -23,7 +23,6 @@
2424
2525 private $_consumerKey;
2626 private $_consumerSecret;
27 - private $_oauthCallback;
2827 private $_twUserTable = 'twitter_user';
2928
3029 public function __construct(){
@@ -32,20 +31,19 @@
3332
3433 $this->_consumerKey = $wgConsumerKey;
3534 $this->_consumerSecret = $wgConsumerSecret;
36 - $this->_oauthCallback = 'https://'.$_SERVER['SERVER_NAME'].$wgScriptPath.'/index.php/Special:TwitterLogin/callback';
3735 }
3836
3937 // default method being called by a specialpage
4038 public function execute( $parameter ){
4139 switch($parameter){
4240 case 'redirect':
43 - $this->_redirect();
 41+ $this->_redirect();
4442 break;
4543 case 'callback':
46 - $this->_handleCallback();
 44+ $this->_handleCallback();
4745 break;
4846 default:
49 - $this->_default();
 47+ $this->_default();
5048 break;
5149 }
5250
@@ -59,7 +57,7 @@
6058 if ( !$wgUser->isLoggedIn() ) {
6159 $wgOut->addWikiText( wfMsg( 'twitterlogin-signup') );
6260
63 - $wgOut->addHTML( '<a href="' . $wgScriptPath . '/index.php/Special:TwitterLogin/redirect">'
 61+ $wgOut->addHTML( '<a href="' . $this->getTitle( 'redirect' )->getFullURL() .'">'
6462 .'<img src="' . $wgExtensionAssetsPath . '/TwitterLogin/' .
6563 'images/sign-in-with-twitter-d.png"/></a>' );
6664 } else {
@@ -110,10 +108,12 @@
111109 // Creating OAuth object
112110 $connection = new TwitterOAuth( $this->_consumerKey, $this->_consumerSecret );
113111
 112+ // set callback url
 113+ $oauthCallback = $this->getTitle( 'callback' )->getFullURL();
 114+
114115 // Getting temporary credentials
115 - $request_token = $connection->getRequestToken( $this->_oauthCallback );
 116+ $request_token = $connection->getRequestToken( $oauthCallback );
116117
117 -
118118 // set returnto url
119119 $_SESSION['returnto'] = ( $wgRequest->getText( 'returnto' ) ) ? $wgRequest->getText( 'returnto' ) : '';
120120
@@ -225,7 +225,7 @@
226226 private function _storeInTable( $user, $screen_name ){
227227 $dbw = wfGetDB(DB_MASTER);
228228 $dbw->insert( $this->_twUserTable,
229 - array('user_id' => $user->getId(), 'twitter_id' => $screen_name),
 229+ array('tl_user_id' => $user->getId(), 'tl_twitter_id' => $screen_name),
230230 __METHOD__,
231231 array()
232232 );
@@ -234,10 +234,11 @@
235235 // user already exists... was it created from twitter or did it alread exist before?
236236 private function _isCreatedFromTwitter( $user ){
237237 $dbr = wfGetDB(DB_SLAVE);
238 - $res = $dbr->select( $this->_twUserTable, 'twitter_id', //'relation'
239 - array( 'user_id' => $user->getId() ),
 238+ $res = $dbr->select( $this->_twUserTable, 'tl_twitter_id', //'tl_relation'
 239+ array( 'tl_user_id' => $user->getId() ),
240240 __METHOD__
241241 );
 242+
242243 if ( $row = $dbr->fetchObject( $res ) ) {
243244 $dbr->freeResult( $res );
244245 $user->saveToCache();

Follow-up revisions

RevisionCommit summaryAuthorDate
r99398svn:eol-style nativeialex14:03, 10 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r99355initial import of TwitterLogin extensionkwisatz16:01, 9 October 2011
r99357added message to special page when already logged inkwisatz16:09, 9 October 2011

Comments

#Comment by Nikerabbit (talk | contribs)   21:34, 9 October 2011

Sql files don't have svn:eol-style = native?

#Comment by Clausekwis (talk | contribs)   16:24, 10 October 2011

Excuse me, I had forgotten to set that in auto-props

Status & tagging log