I'm receiving the following error sporadically:
Warning: Invalid argument supplied for foreach() in twitter_pull_preprocess() (line 65 of /sites/all/modules/twitter_pull/twitter_pull.module).

When I google the error, I don't see any Drupal support, but I see a ton of websites that seem to be having the same error.

What I did to create the error:

  1. Installed the twitter pull module
  2. Created a custom pane on my homepage panel
  3. Set the editor text format to PHP code
  4. Inserted the following code:
    <?php if (function_exists('twitter_pull_render')) { print twitter_pull_render('@drupal', 'Twitter Feed', 3); } ?>
  5. Saved panel and went to my homepage

Like I said... the error only occurs sporadically. It works for a while and then throws an error. Any help would be much appreciated!

Comments

Adam Wood’s picture

I've just got the same error...

I've installed in on a fresh install, installed the module, enabled the php code, added the default code into the block.

I'm getting the error on every page and the block isn't pulling the tweets through, just displaying the feed title.

Adam Wood’s picture

I've rolled back to rc1 and it's working fine.

frichman’s picture

I have the same error, only when search for users with an @ tag.

frichman’s picture

Also get this error message:

Could not retrieve data from Twitter. Bad Request This site may be subject to rate limiting. For more information, see: http://apiwiki.twitter.com/Rate-limiting

Because it is unauthenticated, it should be limited to 150 requests per hour, but I do not think I have gone over that.

beatnykk’s picture

Status: Active » Needs work

I have this error too, slowing down the page loading drastically, sometimes working after cache clear ...
I'm back to rc1 also, working fine.

sakadava’s picture

I got this error and debug revealed that in twitter_pull_preprocess(), $variables['tweets'] was set to the string "No Tweets", i.e. not an array which is what is expected, and hence the php error. "No Tweets" is returned when Twitter returns 400 (indicating possibly rate limiting).

The site isn't particularly busy so I question whether this is a case of genuine rate limiting of the site - maybe Twitter returns an error code 400 when it's rate limiting more generally (e.g. due to Olympics overload)? After a while the error went away - perhaps Twitter was no longer rate limiting.

rc1 uses different code and behaves differently. I switched to rc1 - it didn't generate the error message and didn't display any tweets either so it looks like it handles this situation without error.

Looks like twitter_pull_preprocess() should handle string values, like "No Tweets" when Twitter rate limits - possibly something like this:

line 64:    if (!empty($variables['tweets'])) {

changes to this:

line 64:    if (is_array($variables['tweets'])) {

Sorry don't know how to do patches. Hope that helps anyhow.
Simon

wbobeirne’s picture

StatusFileSize
new624 bytes

Just wrote a patch for this and was looking to post it, this seems like the spot. #6 had it, but instead of removing the !empty, I'm going to add && is_array, as empty can be true an empty array. Attached is the patch.

jlancaster’s picture

Version: 7.x-1.0-rc2 » 7.x-1.0-rc3

Confirmed that path in #7's patch fixes the issue. Issue is still persistent in rc3 and dev branch so I'm tagging this to the newest version.

rplescia’s picture

Version: 7.x-1.0-rc3 » 7.x-1.0-rc4

I have applied the patch in #7 but I still get the same issue in rc4

glynster’s picture

Patch works well, thanks for the help.

wbobeirne’s picture

Status: Needs work » Reviewed & tested by the community
jec006’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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