sb3108sa / phpbrowscap

Automatically exported from code.google.com/p/phpbrowscap
GNU Lesser General Public License v2.1
0 stars 0 forks source link

Cache gets updated even if the received contents are not valid #17

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Change the URL to an invalid one
2. Run a cache update

What is the expected output? What do you see instead?
Well, what I would expect is for the cache to remain untouch if the update 
wasn't successful. What I see is the data file being corrupted and then the 
browscap failing.

What version of the product are you using? On what operating system?
0.7 on Linux.

Please provide any additional information below.

I added a fix to the issue in the method _getRemoteData:

$info = curl_getinfo($ch);

if (isset($info['http_code']) && $info['http_code'] !== 200) {
    $file = false;
}

Right after the curl call, so, if the call was not successful the cache remains 
as it was.

The problem is actually more realistic when you made requests beyond the allow 
maximum (thus getting a 403 error).

Hope it helps. 

Original issue reported on code.google.com by mchoj...@gmail.com on 4 Jan 2011 at 2:47