No data added to {twitter_account}
webchick - February 22, 2009 - 01:39
| Project: | |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | duplicate |
Jump to:
Description
See screenshot:

| Project: | |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | duplicate |
See screenshot:

#1
Ok, figured out the problem. In twitter_user_save(), there's this logic:
<?phpif (!empty($statuses)) {
twitter_cache_account($statuses[0]['account']);
twitter_touch_account($account['screen_name']);
}
?>
Since my twitter account has no tweets yet, $statuses is indeed empty. As a consequence, no information gets saved to the twitter_account table, so the table comes back blank.
I see this was introduced here: http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/twitter/twi..., the log message of which reads "Compatability with the latest Views 2 dev release and the forthcoming RC2." I assume this means that Views freaks out when there's info in this table, but not any info in the twitter table? Still, on an initial import, this really looks odd.
I'm not sure if the answer is to run this logic on initial account setup regardless, or if it's just to put some logic in the form validation that prevents new accounts from being imported, but at least this is now documented for the next poor slob. :)
#2
More descriptive title.
#3
ran into this too. I figured out what's missing.
The record written to twitter_account is using drupal_write_record. The array that is passed to drupal_write_record has all the fields of the twitter_account table inside except for the 'last_refreshed' field.
At least for me, there is no last_refreshed field that is returned from Twitter when fetching the statuses array. There is a field called 'created_time' but it's outside of the 'account' array returned by Twitter. Since last_refreshed is a required field in the twitter_account table and there is no DEFAULT, the drupal_write_record is failing.
You can test this by changing the twitter_cache_account function in twitter.inc from:
function twitter_cache_account($twitter_account = array()) {db_query("DELETE FROM {twitter_account} WHERE twitter_uid = %d", $twitter_account['twitter_uid']);
drupal_write_record('twitter_account', $twitter_account);
}
to
function twitter_cache_account($twitter_account = array()) {db_query("DELETE FROM {twitter_account} WHERE twitter_uid = %d", $twitter_account['twitter_uid']);
$twitter_account['last_refresh'] = time();
drupal_write_record('twitter_account', $twitter_account);
}
So the logic needs to be rewritten to get at the created_time Twitter field to use in the account array passed to drupal_write_record.
#4
related to: #301317: SQL errors on editing Twitter Accounts
#5
Another poor slob here ;-)
Data is added to {twitter_user} but not to {twitter_account}:
In all these cases name and description are blank, the user has no idea what is happening, and is unable to correct the situation.
What's more:
#6
subscribing
#7
Appears to be a duplicate of #301317: SQL errors on editing Twitter Accounts