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:
- Installed the twitter pull module
- Created a custom pane on my homepage panel
- Set the editor text format to PHP code
- Inserted the following code:
<?php if (function_exists('twitter_pull_render')) { print twitter_pull_render('@drupal', 'Twitter Feed', 3); } ?>
- 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
Comment #1
Adam Wood commentedI'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.
Comment #2
Adam Wood commentedI've rolled back to rc1 and it's working fine.
Comment #3
frichman commentedI have the same error, only when search for users with an @ tag.
Comment #4
frichman commentedAlso 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.
Comment #5
beatnykk commentedI have this error too, slowing down the page loading drastically, sometimes working after cache clear ...
I'm back to rc1 also, working fine.
Comment #6
sakadava commentedI 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:
changes to this:
Sorry don't know how to do patches. Hope that helps anyhow.
Simon
Comment #7
wbobeirne commentedJust 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.
Comment #8
jlancaster commentedConfirmed 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.
Comment #9
rplescia commentedI have applied the patch in #7 but I still get the same issue in rc4
Comment #10
glynster commentedPatch works well, thanks for the help.
Comment #11
wbobeirne commentedComment #12
jec006 commentedCommitted, thanks http://drupal.org/commitlog/commit/12844/cd59ab66df45e4b34389b5cf1db9fa9...