Fresh installation. Attempting to add a Twitter account.

Notice: Undefined property: stdClass::$data in Twitter->request() (line 280 of /var/aegir/platforms/drupal-7.10/sites/all/modules/twitter/twitter.lib.php).

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'twitter_uid' cannot be null: INSERT INTO {twitter_account} (twitter_uid, screen_name, name, location, description, followers_count, friends_count, statuses_count, favourites_count, url, protected, profile_image_url, profile_background_color, profile_text_color, profile_link_color, profile_sidebar_fill_color, profile_sidebar_border_color, profile_background_image_url, profile_background_tile, verified, created_at, created_time, utc_offset, password, oauth_token, oauth_token_secret, uid) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15, :db_insert_placeholder_16, :db_insert_placeholder_17, :db_insert_placeholder_18, :db_insert_placeholder_19, :db_insert_placeholder_20, :db_insert_placeholder_21, :db_insert_placeholder_22, :db_insert_placeholder_23, :db_insert_placeholder_24, :db_insert_placeholder_25, :db_insert_placeholder_26); Array ( [:db_insert_placeholder_0] => [:db_insert_placeholder_1] => [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => [:db_insert_placeholder_8] => [:db_insert_placeholder_9] => [:db_insert_placeholder_10] => [:db_insert_placeholder_11] => [:db_insert_placeholder_12] => [:db_insert_placeholder_13] => [:db_insert_placeholder_14] => [:db_insert_placeholder_15] => [:db_insert_placeholder_16] => [:db_insert_placeholder_17] => [:db_insert_placeholder_18] => [:db_insert_placeholder_19] => [:db_insert_placeholder_20] => [:db_insert_placeholder_21] => [:db_insert_placeholder_22] => 0 [:db_insert_placeholder_23] => [:db_insert_placeholder_24] => [:db_insert_placeholder_25] => [:db_insert_placeholder_26] => 1 ) in twitter_account_save() (line 56 of /var/aegir/platforms/drupal-7.10/sites/all/modules/twitter/twitter.inc).

CommentFileSizeAuthor
#10 twitter-1383992-10.patch671 bytesManuel Garcia
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

troe-lcog’s picture

Priority: Normal » Major

Same issue. Subscribed.

steinmb’s picture

Hi. Are you getting this with or without OAuth?

Anonymous’s picture

Twitter.module only. No Oauth.

steinmb’s picture

Thanx. Another thing, could you also have a look in your Drupal log for related error messages when you try to add an Twitter account?

Anonymous’s picture

Here is the error that shows up in syslog in addition to the other two that show up in the error box above.

Jan 10 21:10:02 19264 drupal: http://d7.example.com|1326251370|twitter|127.0.0.1|http://d7.example.com/user/1/edit/twitter|http://d7.example.com/user/1/edit/twitter|1||exception 'TwitterException' with message 'Connection timed out' in /var/aegir/platforms/drupal-7.10/sites/all/modules/twitter/twitter.lib.php:284 Stack trace: #0 /var/aegir/platforms/drupal-7.10/sites/all/modules/twitter/twitter.lib.php(227): Twitter->request('http://api.twit...', Array, 'GET') #1 /var/aegir/platforms/drupal-7.10/sites/all/modules/twitter/twitter.lib.php(199): Twitter->call('users/show', Array, 'GET', false) #2 /var/aegir/platforms/drupal-7.10/sites/all/modules/twitter/twitter.pages.inc(313): Twitter->users_show('VMdoh', false) #3 /var/aegir/platforms/drupal-7.10/includes/form.inc(1430): twitter_account_form_submit(Array, Array) #4 /var/aegir/platforms/drupal-7.10/includes/form.inc(844): form_execute_handlers('submit', Array, Array) #5 /var/aegir/platforms/drupal-7.10/includes

I'm starting to think it's on my end in my case.

EDIT: Well, I thought that, but I'm not sure. It works on one server, but not on another, which is what leads me to think it may be on my end with the connection timing out.

-BUT-

Doing a bootstrap with a drupal_http_request() by itself works for everything except twitter.com.

Anonymous’s picture

Priority: Major » Minor

Just got a notification from the VPS provider that it is a routing issue upstream from them (which I've now confirmed with traceroute). Sorry about that - just made an assumption.

troe-lcog: You might check with your provider and see if they are having the same issue.

steinmb’s picture

Title: PDO Exception: Integrity constraint violation in twitter_account_save() » Communication problems causes PDO Exception: Integrity constraint violation in twitter_account_save() when adding accounts.
Priority: Minor » Normal

Ah. Glad to hear you where able to find the problem. On the other hand this module should not throw PDO exceptions due to network problems, but I'm afraid that could be a part of a more general discussion. Prob. also related to #1358308: Use OAuth to pull tweets if the account is authenticated and other.

troe-lcog’s picture

Thanks for pointing me in the right direction, Brian. It was our host blocking the call.

peterpolman’s picture

Hi guys!

I got in touch with my hostingprovider about this problem and they ask me to what host, ip or through wich port the module wants to connect. Then they can check if the connection is is being blocked by their routers or that twitter blocks them out.

I found this array in de twitter.lib.php file TwitterConf class:
private $attributes = array(
'host' => 'twitter.com',
'api' => 'api.twitter.com',
'search' => 'search.twitter.com',
'tiny_url' => 'tinyurl.com',
);

Is it api.twitter.com that is blocked by hostingproviders routers? Because that one also pops up in the Drupal error logs.

Manuel Garcia’s picture

FileSize
671 bytes

I just print_r'ed the response object in the twitter lib file (here at drupaldevdays barcelona), and here it is:

stdClass Object
(
    [request] => GET /1/users/show.json?screen_name=drupalero HTTP/1.0
Host: api.twitter.com
User-Agent: Drupal (+http://drupal.org/)


    [data] => {"request":"\/1\/users\/show.json?screen_name=drupalero","error":"Rate limit exceeded. Clients may not make more than 150 requests per hour."}
    [protocol] => HTTP/1.0
    [status_message] => Bad Request
    [headers] => Array
        (
            [x-ratelimit-limit] => 150
            [x-ratelimit-remaining] => 0
            [x-ratelimit-reset] => 1339861582
            [x-ratelimit-class] => api
            [content-type] => application/json;charset=utf-8
            [set-cookie] => guest_id="v1:133986011198712901";Expires=Mon, 16-Jun-14 15:21:51 GMT;Path=/;Domain=.twitter.com
            [status] => 400 Bad Request
            [x-transaction] => 52b16a27f0cb0480
            [x-frame-options] => SAMEORIGIN
            [date] => Sat, 16 Jun 2012 15:21:51 GMT
            [content-length] => 142
            [connection] => keep-alive
            [server] => tfe
        )

    [code] => 400
    [error] => Bad Request
)

As you can see, our network's IP has ran out of x-ratelimit-remaining.... so we dont get data back.

So we did some backtracing, find attached the patch that prevents the module from trying to save an empty account.

Manuel Garcia’s picture

Status: Active » Needs review
juampynr’s picture

Title: Communication problems causes PDO Exception: Integrity constraint violation in twitter_account_save() when adding accounts. » Error when adding an account: PDO Exception: Integrity constraint violation in twitter_account_save()
Version: 7.x-3.0-beta4 » 7.x-3.x-dev
Status: Needs review » Fixed

Thanks everyone who helped debugging this.

I have fixed the way we handle errors returned by the Twitter API and after my testing there are no more Integrity Errors and instead the user sees an alert stating what happened.

http://drupalcode.org/project/twitter.git/commitdiff/211ef36

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

xurizaemon’s picture

Found a couple of issues which stemmed from 211ef36.

* Exception handling was not PHP5.2-compatible, and a fix for this is in #1814642: Invalid handling of exceptions causes fatal errors on PHP5.2.
* In event of Twitter returning a 401 unauthorised, Twitter::parse_response() returned string $data, causing a fatal error when attempting to use $data['errors'][0]['message'].

These will be fixed as part of #1814642: Invalid handling of exceptions causes fatal errors on PHP5.2.