{"record":{"id":"3733d2b81aa6ccb0","repo":"octobercms/october","slug":"the-s-modifier-takes-exactly-one-argument-2-gi","errorCode":null,"errorMessage":"The \"%s\" modifier takes exactly one argument (2 given).","messagePattern":"The \"(.+?)\" modifier takes exactly one argument \\(2 given\\)\\.","errorType":"exception","errorClass":"Twig\\Error\\SyntaxError","httpStatus":null,"severity":"error","filePath":"modules/cms/twig/tokenparser/CacheTokenParser.php","lineNumber":41,"sourceCode":"        $key = $this->parser->parseExpression();\n\n        $ttl = null;\n        while ($stream->test(Token::NAME_TYPE)) {\n            $k = $stream->getCurrent()->getValue();\n            if (!in_array($k, ['ttl'], true)) {\n                throw new SyntaxError(sprintf('Unknown \"%s\" configuration.', $k), $stream->getCurrent()->getLine(), $stream->getSourceContext());\n            }\n\n            $stream->next();\n            $stream->expect(Token::OPERATOR_TYPE, '(');\n            $line = $stream->getCurrent()->getLine();\n            if ($stream->test(Token::PUNCTUATION_TYPE, ')')) {\n                throw new SyntaxError(sprintf('The \"%s\" modifier takes exactly one argument (0 given).', $k), $line, $stream->getSourceContext());\n            }\n\n            $arg = $this->parser->parseExpression();\n            if ($stream->test(Token::PUNCTUATION_TYPE, ',')) {\n                throw new SyntaxError(sprintf('The \"%s\" modifier takes exactly one argument (2 given).', $k), $line, $stream->getSourceContext());\n            }\n            $stream->expect(Token::PUNCTUATION_TYPE, ')');\n\n            if ($k === 'ttl') {\n                $ttl = $arg;\n            }\n        }\n\n        $stream->expect(Token::BLOCK_END_TYPE);\n        $body = $this->parser->subparse([$this, 'decideCacheEnd'], true);\n        $stream->expect(Token::BLOCK_END_TYPE);\n\n        $body = new CacheNode($key, $ttl, $body, $token->getLine());\n\n        return new PrintNode(new RawFilter($body), $token->getLine());\n    }\n\n    /**","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/cms/twig/tokenparser/CacheTokenParser.php#L23-L59","documentation":"The ttl modifier of the {% cache %} tag takes exactly one argument. After parsing the first expression, the parser checks for a comma; presence of one means at least two arguments were supplied and it throws this SyntaxError (the message always says 2 given, even for more).","triggerScenarios":"Writing {% cache 'sidebar' ttl(3600, 60) %} during template compilation - a comma after the TTL expression hits the punctuation check; common when porting cache()->remember($key, $ttl, $callback) muscle memory into the tag.","commonSituations":"Developers translating PHP cache calls 1:1 into Twig; attempts to pass separate value and unit arguments (ttl(60, 'minutes')).","solutions":["Keep a single expression: {% cache 'sidebar' ttl(3600) %} (minutes).","Compute composite values in PHP or via a Twig expression before the tag, not as extra arguments.","Re-save and reload - compile fails until the tag is fixed."],"exampleFix":"{# before #}\n{% cache 'sidebar' ttl(3600, 60) %}\n\n{# after #}\n{% cache 'sidebar' ttl(3600) %}","handlingStrategy":"validation","validationCode":"$env = app('twig.environment');\ntry {\n    $env->parse($env->tokenize(new \\Twig\\Source($templateBody, $fileName)));\n} catch (\\Twig\\Error\\SyntaxError $e) {\n    // reject multi-argument ttl(a, b) at lint time\n}","typeGuard":null,"tryCatchPattern":"try {\n    $env->parse($env->tokenize(new \\Twig\\Source($body, $name)));\n} catch (\\Twig\\Error\\SyntaxError $e) {\n    // flag 'takes exactly one argument (2 given)' for immediate fix\n}","preventionTips":["The ttl modifier takes one value in minutes - compute composites in PHP.","Do not transliterate cache()->remember($key, $ttl, $cb) signatures into the tag.","Lint templates in CI to catch arity mistakes before deploy."],"tags":["twig","syntax-error","cache-tag","template","too-many-arguments"],"backgroundTag":"template-syntax-error","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}