{"record":{"id":"10d5148eabc34109","repo":"getgrav/grav","slug":"unsupported-version-s","errorCode":null,"errorMessage":"Unsupported version %s","messagePattern":"Unsupported version (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"system/src/Grav/Framework/ContentBlock/ContentBlock.php","lineNumber":300,"sourceCode":"\n    /**\n     * @return string\n     */\n    protected function generateId()\n    {\n        return uniqid('', true);\n    }\n\n    /**\n     * @param array $serialized\n     * @return void\n     * @throws RuntimeException\n     */\n    protected function checkVersion(array $serialized)\n    {\n        $version = isset($serialized['_version']) ? (int) $serialized['_version'] : 1;\n        if ($version !== $this->version) {\n            throw new RuntimeException(sprintf('Unsupported version %s', $version));\n        }\n    }\n}\n","sourceCodeStart":282,"sourceCodeEnd":304,"githubUrl":"https://github.com/getgrav/grav/blob/6040efed04efa69b8209448ed81308e7c24147c2/system/src/Grav/Framework/ContentBlock/ContentBlock.php#L282-L304","documentation":"ContentBlock::checkVersion() runs at the top of build(): it reads '_version' from the serialized array (defaulting to 1) and requires it to equal the block class's own $version. A mismatch throws RuntimeException('Unsupported version N') — a format-compatibility guard that rejects block data serialized by a different Grav release instead of silently misinterpreting it. It normally reaches callers wrapped as 'Cannot unserialize Block: Unsupported version N'.","triggerScenarios":"fromArray()/build() receives arrays whose '_version' differs from the running class's version: cache serialized before a Grav upgrade replayed after it; data written by a newer Grav read by an older install (rollback); block arrays persisted long-term (DB/session) instead of being treated as disposable cache.","commonSituations":"Deploying a new Grav version without clearing cache; rolling back a release while the cache survives; multi-server setups running mixed Grav versions behind one cache backend; importing cache or backups from another environment.","solutions":["Clear the cache after every Grav upgrade: bin/grav clear-cache (or remove the cache/* directories).","Verify all servers/environments run the same Grav version so serialized '_version' values match.","Treat serialized blocks as disposable cache: catch the RuntimeException and regenerate the block from source content.","If you persist block arrays yourself, key them by Grav version and discard old keys on upgrade."],"exampleFix":"// before\n$block = ContentBlock::fromArray($cached);\n\n// after\ntry {\n    $block = ContentBlock::fromArray($cached);\n} catch (\\RuntimeException $e) {\n    // stale cache with a different block format version: drop and regenerate\n    $cache->delete($key);\n    $block = ContentBlock::fromArray($fresh->toArray());\n}","handlingStrategy":"try-catch","validationCode":"// Compare stored format version against the running version before fromArray()\n$expected = (int) ($freshBlock->toArray()['_version'] ?? 1);\nif ((int) ($serialized['_version'] ?? 1) !== $expected) {\n    $serialized = $freshBlock->toArray(); // regenerate instead of unserializing\n}","typeGuard":null,"tryCatchPattern":"try {\n    $block = ContentBlock::fromArray($cached);\n} catch (\\RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'Unsupported version')) {\n        $cache->delete($key); // stale format: drop and rebuild\n        $block = ContentBlock::fromArray($fresh->toArray());\n    } else {\n        throw $e;\n    }\n}","preventionTips":["Clear the cache after every Grav upgrade — serialized block format changes with releases.","Keep all nodes in multi-server setups on the same Grav version.","Never persist block arrays longer-term than the version that wrote them."],"tags":["php","grav","content-block","version-mismatch","cache-invalidation"],"backgroundTag":"cache-format-version-mismatch","analyzedSha":"6040efed04efa69b8209448ed81308e7c24147c2","analyzedAt":"2026-08-17T05:07:31.593Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}