After upgrading to version 6.x-5.0 of the Twitter module, I got this error when I tried running cron.php on my site:

Fatal error: Call to a member function user_timeline() on a non-object in /Users/sheldonrampton/Sites/nysenate/branches/nys_srv3/sites/all/modules/contrib/twitter/twitter.inc on line 187

Comments

sheldon rampton’s picture

Version: 6.x-5.0 » 6.x-5.x-dev
Status: Active » Needs review
StatusFileSize
new352 bytes

Here's a patch that eliminates the fatal error.

radimklaska’s picture

Hi, I have same issue. Your patch removes the error, but I feel like it fixes the consequences, not the real cause.

I have some suspicions that in my case I caused this by doing update without dependencies. I was updating from 6.x-3.something directly to 6.x-5.0 without adding oauth... I will take closer look later.

juampynr’s picture

Status: Needs review » Needs work

Agree with @radimklaska, there is a deeper error in the logic.

This situation can happen when you delete the only authenticated account in your site. Please try the following steps to see if you get the error again:

1. Delete all twitter accounts.
2. Add an authenticated account.
3. Add a non-authenticated account.
4. Delete the authenticated one.
5. Run cron

I think you will get the error because twitter_cron will call user_timeline but crash since there is no authenticated account.

sheldon rampton’s picture

Hm, well, tritter_cron should do something more graceful than crash with a fatal error when there is no authenticated account. The fatal error shuts down the cron process entirely, which will interfere with the proper functioning of other modules that have cron hooks.

damienmckenna’s picture

Title: Fatal error: Call to a member function user_timeline » Failure when there are no authenticated accounts left
Issue summary: View changes
Parent issue: » #2402311: Plan for Twitter v6.x-5.2 release
Related issues: +#2402307: Plan for Twitter v7.x-5.9 release, +#2402309: Plan for Twitter v7.x-6.0 release

I don't think it should block you when trying to delete the last authenticated Twitter account, but maybe there should be some warnings, etc. And it definitely should be handled more gracefully.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new3.91 KB

This makes an important change - when twitter_connect() is called the first global authenticated account will be used for the API calls. This will solve the problem of an average user's Twitter account being used for API calls. It also logs a message via watchdog() if there are no global authenticated accounts to use. It also updates all scenarios where twitter_connect() is used to verify that an account was returned.

damienmckenna’s picture

StatusFileSize
new4.28 KB

Minor tweaks.

damienmckenna’s picture

StatusFileSize
new4.1 KB

This reverts part of the change so it no longer checks for a global authenticated account, and no longer will try to use another account if the submitted account is not authenticated.

damienmckenna’s picture

Version: 6.x-5.x-dev » 7.x-5.x-dev
StatusFileSize
new4.7 KB

Ported to 7.x-5.x

damienmckenna’s picture

StatusFileSize
new3.67 KB

Ported to 7.x-6.x.

Status: Needs review » Needs work

The last submitted patch, 10: twitter-n1911494-10-7.x-6.x.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Fixed

Committed.

  • DamienMcKenna committed 1943f10 on 7.x-5.x
    Issue #1911494 by DamienMcKenna, Sheldon Rampton: Don't assume...

  • DamienMcKenna committed 42c5815 on 7.x-6.x
    Issue #1911494 by DamienMcKenna, Sheldon Rampton: Don't assume...

Status: Fixed » Closed (fixed)

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