Closed xuanskyer closed 7 years ago
How are you getting this? The MaxMind\Db\Reader
returns an array or null
. If we are getting something else back, it is a bug and should be a fatal error.
I haven't reproduced the mistake yet. Only found this error in php_errors.log :(
What version of this package and MaxMind\Db\Reader
are you using? Are you using the C extension?
@oschwald
geoip2 version 2.4.2 maxmind-db/reader version 1.1.1
using php package, not C extension.
Have you been getting any InvalidDatabaseException
exceptions? My first thought is that the database file is corrupt in some way. Generally, this would cause the above exception to be thrown, but it could occasionally result in an error like this.
Error: Cannot use string offset as an array
# 6: vendor/geoip2/geoip2/src/Database/Reader.php(195): modelFor
with data $class = Country
, $ipAddress = 4. ...
, $type = Country
# 5: vendor/geoip2/geoip2/src/Database/Reader.php(87): country
with data $ipAddress = 4.15.238.175
Hope that helps the error hunting
Upgrading the ip database removed this problem for me but I assume that should not be able to happen
Besides this error, were you also getting exceptions from MaxMind\Db\Reader
? The only way this could happen is on a corrupt database, which should be generating an exception on almost every call.
You are probably correct, it appears the ip-range number above went back to triggering the same error, I suspect something in the release process causes the problem.
Oddly it only triggers on the very first ip-ranges, the majority of requests work fine but 1. 2. 4. & 5. ranges have all caused the error to happen. Possibly the corruption is limited there, for whatever reasons.
Would it be possible for you to send me the corrupt database at goschwald@maxmind.com? Thanks!
PHP Fatal error: Cannot use string offset as an array in /vendor/geoip2/geoip2/src/Database/Reader.php on line 195