Closed (fixed)
Project:
Twitter
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
3 Nov 2011 at 20:20 UTC
Updated:
20 Nov 2011 at 02:30 UTC
Hi,
While trying to edit a user account via the administration panel, I noticed I was unable to add twitter accounts. I did not have the time yet to make a diff but here is what should fix it.
twitter.pages.inc on line 304
function twitter_account_form_submit($form, &$form_state) {
module_load_include('lib.php', 'twitter');
module_load_include('inc', 'twitter');
$name = $form_state['values']['screen_name'];
$twitter = new Twitter($name);
$account = $twitter->users_show($name, false);
$account->set_auth($form_state['values']);
twitter_account_save($account, TRUE);
}
becomes
function twitter_account_form_submit($form, &$form_state) {
module_load_include('lib.php', 'twitter');
module_load_include('inc', 'twitter');
$user = user_load($form_state['values']['uid']);
$name = $form_state['values']['screen_name'];
$twitter = new Twitter($name);
$account = $twitter->users_show($name, false);
$account->set_auth($form_state['values']);
twitter_account_save($account, TRUE, $user);
}
Hope this helps anyone.
Comments
Comment #1
juampynr commentedThere were errors related to add an account fixed at #1253008: Twitter crashes when adding an account without password and #1192138: Error when adding/associating a Twitter account to a site account.
Please do upgrade to the latest stable version available at http://drupal.org/project/twitter.
Cheers
Comment #2
cwithout commentedI installed the latest stable version yesterday and noticed this same issue. Those other 2 are not related.
When an administrator attempts to add a Twitter account to another user, it instead gets added to that administrator's account. As an administrative user, that's not how I'd expect it to behave. That also leaves administrators unable to add a Twitter account to other users without logging in as that user.
I also don't have time at the moment to turn the above into a patch, but upon a single glance, it looks like it would solve the issue.
Comment #3
juampynr commentedGreat spot, I could recreate this error on the Drupal 7 version when not using OAuth, and on the Drupal 6 version using OAuth.
Drupal 7 fix: http://drupalcode.org/project/twitter.git/commitdiff/94350659f58060ae7f7...
Drupal 6 fix: http://drupalcode.org/project/twitter.git/commitdiff/5c618b4c538cc26045a...
Thanks.