{"record":{"id":"33775ab8bf72cbc0","repo":"yiisoft/yii2","slug":"the-user-application-component-must-be-available-t","errorCode":null,"errorMessage":"The user application component must be available to specify roles in AccessRule.","messagePattern":"The user application component must be available to specify roles in AccessRule\\.","errorType":"exception","errorClass":"InvalidConfigException","httpStatus":null,"severity":"error","filePath":"framework/filters/AccessRule.php","lineNumber":235,"sourceCode":"    /**\n     * @param User $user the user object\n     * @return bool whether the rule applies to the role\n     * @throws InvalidConfigException if User component is detached\n     */\n    protected function matchRole($user)\n    {\n        $items = empty($this->roles) ? [] : $this->roles;\n\n        if (!empty($this->permissions)) {\n            $items = array_merge($items, $this->permissions);\n        }\n\n        if (empty($items)) {\n            return true;\n        }\n\n        if ($user === false) {\n            throw new InvalidConfigException('The user application component must be available to specify roles in AccessRule.');\n        }\n\n        foreach ($items as $item) {\n            if ($item === '?') {\n                if ($user->getIsGuest()) {\n                    return true;\n                }\n            } elseif ($item === '@') {\n                if (!$user->getIsGuest()) {\n                    return true;\n                }\n            } else {\n                if (!isset($roleParams)) {\n                    $roleParams = !is_array($this->roleParams) && is_callable($this->roleParams) ? call_user_func($this->roleParams, $this) : $this->roleParams;\n                }\n                if ($user->can($item, $roleParams)) {\n                    return true;\n                }","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/yiisoft/yii2/blob/66f00d18a29b520f85e8e8f1e32d1e7e7b556cac/framework/filters/AccessRule.php#L217-L253","documentation":"Error \"The user application component must be available to specify roles in AccessRule.\" thrown in yiisoft/yii2.","triggerScenarios":"Thrown at framework/filters/AccessRule.php:235 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"66f00d18a29b520f85e8e8f1e32d1e7e7b556cac","analyzedAt":"2026-08-17T05:17:23.470Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}