| @@ -67,14 +67,14 @@ | ||
| 67 | 67 | public $country_whitelist = array(); |
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * Path to downloaded GeoDB. |
| 71 | - * Important: This var doesn't support Union Types. So just 'string'. | |
| 71 | + * An empty string indicates that no database path is saved. | |
| 72 | 72 | * |
| 73 | 73 | * @var string |
| 74 | 74 | * @defender_property |
| 75 | 75 | */ |
| 76 | - public $geodb_path = null; | |
| 76 | + public $geodb_path = ''; | |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * MaxMind license key. |
| 80 | 80 | * |
| @@ -285,11 +285,16 @@ | ||
| 285 | 285 | * |
| 286 | 286 | * @return void |
| 287 | 287 | */ |
| 288 | 288 | protected function after_load(): void { |
| 289 | + // Normalize legacy or imported settings before using this value in filesystem functions. | |
| 290 | + if ( ! is_string( $this->geodb_path ) ) { | |
| 291 | + $this->geodb_path = ''; | |
| 292 | + } | |
| 293 | + | |
| 289 | 294 | if ( |
| 290 | - is_string( $this->geodb_path ) && | |
| 291 | - strlen( $this->geodb_path ) > 0 | |
| 295 | + strlen( $this->geodb_path ) > 0 && | |
| 296 | + ! is_file( $this->geodb_path ) | |
| 292 | 297 | ) { |
| 293 | 298 | $service_geo = wd_di()->get( MaxMind_Geolocation::class ); |
| 294 | 299 | |
| 295 | 300 | preg_match( '#.*[\\\/](.*[\\\/].*)$#', $this->geodb_path, $matches ); |