{"record":{"id":"eb15060e1999b956","repo":"lionsoul2014/ip2region","slug":"failed-to-open-xdb-file-s","errorCode":null,"errorMessage":"failed to open xdb file '%s'","messagePattern":"failed to open xdb file '(.+?)'","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"binding/php/xdb/Searcher.class.php","lineNumber":438,"sourceCode":"    }\n\n    // --- End of static creator\n\n    /**\n     * initialize the xdb searcher\n     * @throws Exception\n     */\n    function __construct($version, $dbFile, $vectorIndex=null, $cBuff=null) {\n        $this->version = $version;\n        // check the content buffer first\n        if ($cBuff != null) {\n            $this->vectorIndex = null;\n            $this->contentBuff = $cBuff;\n        } else {\n            // open the xdb binary file\n            $this->handle = fopen($dbFile, \"r\");\n            if ($this->handle === false) {\n                throw new Exception(\"failed to open xdb file '%s'\", $dbFile);\n            }\n\n            $this->vectorIndex = $vectorIndex;\n        }\n    }\n\n    public function close() {\n        if ($this->handle != null) {\n            fclose($this->handle);\n        }\n    }\n\n    public function getIPVersion() {\n        return $this->version;\n    }\n\n    public function getIOCount() {\n        return $this->ioCount;","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/lionsoul2014/ip2region/blob/c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1/binding/php/xdb/Searcher.class.php#L420-L456","documentation":"PHP constructor guard: fopen() on the xdb file returned false, so the searcher has no readable handle. Common causes are a missing/unreadable file, wrong path, or insufficient file permissions; note the message uses %s-style formatting passed to Exception, so the path may render literally.","triggerScenarios":"Thrown at binding/php/xdb/Searcher.class.php:438 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Confirm the dbFile path is correct and the file exists","Grant the PHP process read permission on the xdb file","Alternatively pass the whole file content via the cBuff parameter to avoid file access entirely"],"exampleFix":null,"handlingStrategy":"try-catch","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"}