northk / twitterfeed

ExpressionEngine module which grabs, caches and displays a public user timeline from Twitter
6 stars 1 forks source link

PHP Errors when working locally #1

Open paynecodes opened 12 years ago

paynecodes commented 12 years ago

The following PHP errors are occurring with the Twitter Feed plugin installed on my local machine only when internet connectivity is disabled. Is this an indicator of what could happen if the script has trouble connecting to Twitter in a production environment?

A PHP Error was encountered

Severity: Warning
Message: curl_error(): 283 is not a valid cURL handle resource
Filename: twitterfeed/twitterfeed_helper.php
Line Number: 334

A PHP Error was encountered

Severity: Warning
Message: curl_error(): 286 is not a valid cURL handle resource
Filename: twitterfeed/twitterfeed_helper.php
Line Number: 334

A PHP Error was encountered

Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at ~/expressionengine//system/codeigniter/system/core/Exceptions.php:170)
Filename: core/Common.php
Line Number: 412

Fatal error: ob_start() [ref.outcontrol]: Cannot use output buffering in output buffering display handlers in ~/expressionengine/system//codeigniter/system/core/Exceptions.php on line 166

northk commented 12 years ago

Hi jpdesigndev, thanks for reporting the problem; I hadn't run into this issue before. It's definitely a bug. If the curl call to get the Twitter feed failed, I was closing the curl connection before getting ahold of the curl error code. That's not going to work!

I'm testing the fix now. If you have time I'd appreciate your testing it as well before I check it in. Here's the updated code, starting with line 329 of twitterfeed_helper.php in the system/expressionengine/third_party/twitterfeed folder:

        $result = curl_exec($curl);

      // if the curl call failed, log the error and return
        if ($result === FALSE)
        {
            $this->EE->TMPL->log_item('Twitterfeed module : cURL exec error : ' . curl_error($curl));     
              curl_close($curl); // close the curl connection *after* getting the error code            
            return FALSE;
        }

      // close the curl connection; there weren't any curl errors
        curl_close($curl); 
paynecodes commented 12 years ago

Weird, but I am not able to replicate the initial issue before implementing this code. Will do my best to make it back around to this, and try to replicate the issue itself.

That being said, the new code seems to work fine, but I can't be sure. Thanks for your help! Awesome!!

paynecodes commented 12 years ago

Just went through another short period of dev time without an internet connection. So far so good in my limited testing.

northk commented 12 years ago

Great, thanks for testing the fix. This kind of thing is hard to test because it depends on experiencing a CURL error during the call to get information from Twitter. That's not going to happen very often.

It's working well for me too; if it's still working well in a week I'll post the change to Github. Thanks again for reporting the problem.