Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

caching Twitter.screen_name makes Twitter::Client.new.user return old user #136

Closed
wants to merge 1 commit into from
Closed

Conversation

kenmazaika
Copy link

Before Patch:
irb(main):001:0> at1 = AccessToken.find(3)
=> #<AccessToken id: 3, secret: "p4EOngHwWi4MsCSy92MgfvV8wgNoyVVTCgLAylKWmas", token: "236155797-kWLr6T5MZdPGmTX2hnQEKHMQEn72tNUlxOyuFDRc", user_id: 7, token_type: "twitter", created_at: "2011-01-09 23:09:24", updated_at: "2011-01-09 23:09:24">
irb(main):002:0> at2 = AccessToken.find(5)
=> #<AccessToken id: 5, secret: "1XZy36MSF1TVlycNHwOhU6hLKCiTKBSQgYZ6yunB0", token: "44006917-TEcF5y8Bj4sWls1Bt8mN3lFISbjK6COJmwIPZnutY", user_id: 10, token_type: "twitter", created_at: "2011-01-16 15:24:16", updated_at: "2011-01-16 15:24:16">
irb(main):003:0> Twitter::Client.new(:oauth_token => at1.token, :oauth_token_secret => at1.secret).user.screen_name
=> "bostontoastm"
irb(main):004:0> Twitter::Client.new(:oauth_token => at2.token, :oauth_token_secret => at2.secret).user.screen_name
=> "bostontoastm"

After Patch:

irb(main):001:0> at1 = AccessToken.find(3)
=> #<AccessToken id: 3, secret: "p4EOngHwWi4MsCSy92MgfvV8wgNoyVVTCgLAylKWmas", token: "236155797-kWLr6T5MZdPGmTX2hnQEKHMQEn72tNUlxOyuFDRc", user_id: 7, token_type: "twitter", created_at: "2011-01-09 23:09:24", updated_at: "2011-01-09 23:09:24">
irb(main):002:0> at2 = AccessToken.find(5)
=> #<AccessToken id: 5, secret: "1XZy36MSF1TVlycNHwOhU6hLKCiTKBSQgYZ6yunB0", token: "44006917-TEcF5y8Bj4sWls1Bt8mN3lFISbjK6COJmwIPZnutY", user_id: 10, token_type: "twitter", created_at: "2011-01-16 15:24:16", updated_at: "2011-01-16 15:24:16">
irb(main):003:0> Twitter::Client.new(:oauth_token => at1.token, :oauth_token_secret => at1.secret).user.screen_name
=> "bostontoastm"
irb(main):004:0> Twitter::Client.new(:oauth_token => at2.token, :oauth_token_secret => at2.secret).user.screen_name
=> "KenMazaika"

@sferik
Copy link
Owner

sferik commented Jan 16, 2011

Would calling Twitter.reset whenever a new client is initialized solve the problem? This solution feels like throwing out the baby with the bathwater.

@kenmazaika
Copy link
Author

In the general case that would probably work, but I don't think it would work in the case of:

twitter1 = Twitter::Client.new(user1's token)
twitter2 = Twitter::Client.new(user2's token)

twitter1.user.screenname

@sferik
Copy link
Owner

sferik commented Jan 16, 2011

I just added a failing test case in cf825ea.

@sferik
Copy link
Owner

sferik commented Jan 16, 2011

Don't set cached screen_name when creating a new API client

Closed by ceeed99.

@kenmazaika
Copy link
Author

Thanks for fixing this so quickly and merging it into master.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants