GaretJax/phpbrowscap

Autoupdate version issue (Affects very much!)

alvassin opened this issue · 4 comments

Sometimes website stops working because of following errors. Is there a way to fix it?

apache error.log:

[error] PHP Warning: file_get_contents(http://browsers.garykeith.com/versions/version-date.asp): failed to open stream: Connection timed out in /var/www/production/library/Browser/Browscap.php on line 744, referer: http://10.250.34.105/
[error] PHP Warning: fsockopen(): unable to connect to browsers.garykeith.com:80 (Connection timed out) in /var/www/production/library/Browser/Browscap.php on line 751, referer: http://10.250.34.105/
[error] PHP Warning: fsockopen(): unable to connect to browsers.garykeith.com:80 (Connection timed out) in /var/www/production/library/Browser/Browscap.php on line 751, referer: http://10.250.34.105/
[error] PHP Warning: file_get_contents(http://browsers.garykeith.com/versions/version-date.asp): failed to open stream: Connection timed out in /var/www/production/library/Browser/Browscap.php on line 744, referer: http://10.250.34.105/
[error] PHP Warning: file_get_contents(http://browsers.garykeith.com/versions/version-date.asp): failed to open stream: Connection timed out in /var/www/production/library/Browser/Browscap.php on line 744, referer: http://10.250.34.105/
[error] PHP Warning: fsockopen(): unable to connect to browsers.garykeith.com:80 (Connection timed out) in /var/www/production/library/Browser/Browscap.php on line 751, referer: http://10.250.34.105/
[error] PHP Warning: file_get_contents(http://browsers.garykeith.com/versions/version-date.asp): failed to open stream: Connection timed out in /var/www/production/library/Browser/Browscap.php on line 744, referer: http://10.250.34.105/
[error] PHP Warning: fsockopen(): unable to connect to browsers.garykeith.com:80 (Connection timed out) in /var/www/production/library/Browser/Browscap.php on line 751, referer: http://10.250.34.105/
[error] PHP Warning: file_get_contents(http://browsers.garykeith.com/versions/version-date.asp): failed to open stream: Connection timed out in /var/www/production/library/Browser/Browscap.php on line 744, referer: http://10.250.34.105/
[error] PHP Warning: fsockopen(): unable to connect to browsers.garykeith.com:80 (Connection timed out) in /var/www/production/library/Browser/Browscap.php on line 751, referer: http://10.250.34.105/

See #24 for why this is :)

I get an exception when the file is not avalaible even if I'm using the silent mode (the bellow link is deliberately wrong)
ErrorException: Warning: file_get_contents(http://tempdownloads.browserscap.com/stream.php?BrowsCapINIsss): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/team/supertag/tms/vendor/phpbrowscap/src/phpbrowscap/Browscap.php line 608

Is the following catch block broken ?

https://github.com/GaretJax/phpbrowscap/blob/master/src/phpbrowscap/Browscap.php#L269

public function getBrowser($user_agent = null, $return_array = false)
{
    // Stuff
    // Find out if the cache needs to be updated
    if (!file_exists($cache_file) || !file_exists($ini_file) || ($interval > $this->updateInterval)) {
        try {
            $this->updateCache();
        } catch (Exception $e) {
            // stuff
            if (!$this->silent) {
                throw $e;
            }

Might be a namespace problem, I tried to put \ and the catch block is called.

catch (\Exception $e)

That's what happens when someone does

use \Exception as BaseException;
class Exception extends BaseException
{}

In their code...

I'm adding a separate issue to kill this terrible terrible code.

I'm closing this issue as the original comment was about the download website change and that has been resolved.