{"record":{"id":"af009c45726d5e1b","repo":"lionsoul2014/ip2region","slug":"invalid-ip-version-number-header-ipversion-af009c","errorCode":null,"errorMessage":"invalid ip version number `{$header['ipVersion']}`","messagePattern":"invalid ip version number `(.+?)`","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"binding/php/xdb/Searcher.class.php","lineNumber":98,"sourceCode":"\n    // version parse from header\n    public static function versionFromHeader($header) {\n        // Old structure 2.0 with IPv4 supports ONLY\n        if ($header['version'] == Structure_20) {\n            return IPv4::default();\n        }\n\n        // structure 3.0 after IPv6 supporting\n        if ($header['version'] != Structure_30) {\n            throw new Exception(\"invalid xdb structure version `{$header['version']}`\");\n        }\n\n        if ($header['ipVersion'] == IPv4VersionNo) {\n            return IPv4::default();\n        } else if ($header['ipVersion'] == IPv6VersionNo) {\n            return IPv6::default();\n        } else {\n            throw new Exception(\"invalid ip version number `{$header['ipVersion']}`\");\n        }\n    }\n\n    // binary string chars implode with space\n    public static function bytesToString($buff, $offset, $length) {\n        $sb = [];\n        for ($i = 0; $i < $length; $i++) {\n            $sb[] = ord($buff[$offset+$i]) & 0xFF;\n        }\n        return '['.implode(' ', $sb).']';\n    }\n\n    // decode a 4bytes long with Little endian byte order from a byte buffer\n    public static function le_getUint32($b, $idx) {\n        $val = (ord($b[$idx])) | (ord($b[$idx+1]) << 8)\n            | (ord($b[$idx+2]) << 16) | (ord($b[$idx+3]) << 24);\n\n        // convert signed int to unsigned int if on 32 bit operating system","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/lionsoul2014/ip2region/blob/c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1/binding/php/xdb/Searcher.class.php#L80-L116","documentation":"PHP versionFromHeader: the structure version is 3.0 but the header's ipVersion field matches neither the IPv4 nor IPv6 number, so the database's address family cannot be resolved; the header is invalid or from an unsupported generator.","triggerScenarios":"Thrown at binding/php/xdb/Searcher.class.php:98 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use an xdb generated by a compatible maker that writes a correct ipVersion header","Re-download the database to rule out corruption","Report files with unknown ipVersion values to the maintainers and regenerate"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1","analyzedAt":"2026-09-02T16:58:39.988Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}