{"record":{"id":"a1e67be8f2c211cf","repo":"doctrine/orm","slug":"invalid-cache-usage-s","errorCode":null,"errorMessage":"Invalid cache usage \"%s\"","messagePattern":"Invalid cache usage \"(.+?)\"","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Mapping/Driver/XmlDriver.php","lineNumber":880,"sourceCode":"            $mapping['options'] = $this->parseOptions($fieldMapping->options->children());\n        }\n\n        return $mapping;\n    }\n\n    /**\n     * Parse / Normalize the cache configuration\n     *\n     * @return mixed[]\n     * @phpstan-return array{usage: int|null, region?: string}\n     */\n    private function cacheToArray(SimpleXMLElement $cacheMapping): array\n    {\n        $region = isset($cacheMapping['region']) ? (string) $cacheMapping['region'] : null;\n        $usage  = isset($cacheMapping['usage']) ? strtoupper((string) $cacheMapping['usage']) : null;\n\n        if ($usage && ! defined('Doctrine\\ORM\\Mapping\\ClassMetadata::CACHE_USAGE_' . $usage)) {\n            throw new InvalidArgumentException(sprintf('Invalid cache usage \"%s\"', $usage));\n        }\n\n        if ($usage) {\n            $usage = (int) constant('Doctrine\\ORM\\Mapping\\ClassMetadata::CACHE_USAGE_' . $usage);\n        }\n\n        return [\n            'usage'  => $usage,\n            'region' => $region,\n        ];\n    }\n\n    /**\n     * Gathers a list of cascade options found in the given cascade element.\n     *\n     * @param SimpleXMLElement $cascadeElement The cascade element.\n     *\n     * @return string[] The list of cascade options.","sourceCodeStart":862,"sourceCodeEnd":898,"githubUrl":"https://github.com/doctrine/orm/blob/d9b9ff73016bf598ae07515f97289ce8074e97a5/src/Mapping/Driver/XmlDriver.php#L862-L898","documentation":"The <cache> element in XML mappings configures second-level caching. Its usage attribute is uppercased and resolved against the ClassMetadata::CACHE_USAGE_* constants; the valid values are READ_ONLY, READ_WRITE and NONSTRICT_READ_WRITE. Anything else (after uppercasing) throws InvalidArgumentException.","triggerScenarios":"Writing <cache usage=\"READONLY\" region=\"my_region\" /> (constant CACHE_USAGE_READONLY does not exist) or invented values like usage=\"ALL\" / usage=\"transactional\"; note underscores are required: READ_ONLY not READONLY.","commonSituations":"Hand-written cache config guessing at constant names; copying cache usage values from other cache libraries (e.g. JPA/Hibernate 'transactional' or Ehcache 'ALL'); typos in case are harmless (strtoupper is applied) but underscore placement is not.","solutions":["Use one of the three valid values: usage=\"READ_ONLY\", usage=\"NONSTRICT_READ_WRITE\" or usage=\"READ_WRITE\".","Pick READ_ONLY for entities that never change after loading (safest and fastest), NONSTRICT_READ_WRITE when slight staleness is acceptable.","Check the constant list in Doctrine\\ORM\\Mapping\\ClassMetadata (CACHE_USAGE_*) if your ORM version differs."],"exampleFix":"<!-- before -->\n<cache usage=\"READONLY\" region=\"user_region\" />\n\n<!-- after -->\n<cache usage=\"READ_ONLY\" region=\"user_region\" />","handlingStrategy":"validation","validationCode":"$usage = strtoupper($usage);\nif (! defined(ClassMetadata::class . '::CACHE_USAGE_' . $usage)) {\n    throw new InvalidArgumentException(\"Invalid second-level cache usage '{$usage}'\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Memorize the three valid usages: READ_ONLY, NONSTRICT_READ_WRITE, READ_WRITE.","Copy cache blocks from the official documentation, not other frameworks.","Enable XSD validation and lint mapping files to catch bad attribute values early."],"tags":["doctrine-orm","xml-mapping","second-level-cache","configuration"],"backgroundTag":"invalid-configuration-value","analyzedSha":"d9b9ff73016bf598ae07515f97289ce8074e97a5","analyzedAt":"2026-08-21T06:13:15.863Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}