{"record":{"id":"381397bcd4e3e021","repo":"FreshRSS/FreshRSS","slug":"0","errorCode":"0","errorMessage":"Current user must not be empty!","messagePattern":"Current user must not be empty!","errorType":"exception","errorClass":"Minz_PDOConnectionException","httpStatus":500,"severity":"error","filePath":"lib/Minz/ModelPdo.php","lineNumber":115,"sourceCode":"\t/**\n\t * Create the connection to the database using the variables\n\t * HOST, BASE, USER and PASS variables defined in the configuration file\n\t * @throws Minz_ConfigurationException\n\t * @throws Minz_PDOConnectionException\n\t */\n\tpublic function __construct(?string $currentUser = null, ?Minz_Pdo $currentPdo = null) {\n\t\tif ($currentUser === null) {\n\t\t\t$currentUser = Minz_User::name();\n\t\t}\n\t\tif ($currentPdo !== null) {\n\t\t\t$this->pdo = $currentPdo;\n\t\t\treturn;\n\t\t}\n\t\tif (self::$dummyConnection) {\n\t\t\treturn;\n\t\t}\n\t\tif ($currentUser == null) {\n\t\t\tthrow new Minz_PDOConnectionException('Current user must not be empty!', '', Minz_Exception::ERROR);\n\t\t}\n\t\tif (self::$usesSharedPdo && self::$sharedPdo !== null && $currentUser === self::$sharedCurrentUser) {\n\t\t\t$this->pdo = self::$sharedPdo;\n\t\t\t$this->current_user = self::$sharedCurrentUser;\n\t\t\treturn;\n\t\t}\n\t\t$this->current_user = $currentUser;\n\t\tif (self::$usesSharedPdo) {\n\t\t\tself::$sharedCurrentUser = $currentUser;\n\t\t}\n\n\t\t$ex = null;\n\t\t//Attempt a few times to connect to database\n\t\tfor ($attempt = 1; $attempt <= 5; $attempt++) {\n\t\t\ttry {\n\t\t\t\t$this->dbConnect();\n\t\t\t\treturn;\n\t\t\t} catch (PDOException $e) {","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/FreshRSS/FreshRSS/blob/95842d81c1b8ab673389544f072559aeb8cd7591/lib/Minz/ModelPdo.php#L97-L133","documentation":"Minz_ModelPdo::__construct(?string $currentUser) guards the user context before connecting: after the dummy-connection shortcut, a null $currentUser - and, due to the loose == comparison, an empty string too - throws Minz_PDOConnectionException('Current user must not be empty!'). No database contact is attempted; the DAO simply has no per-user schema prefix to work with.","triggerScenarios":"Instantiating a DAO or factory while no user is active: a CLI/bootstrap script that never called Minz_User::change(); web context where the session user was not initialized; code passing '' explicitly; running before installation fixed a user name.","commonSituations":"Custom cron/console scripts that include FreshRSS bootstrap constants but forget the user; extensions running early hook code before user setup; partially bootstrapped contexts.","solutions":["Set the user before touching DAOs: Minz_User::change('alice') in scripts, or rely on the authenticated session in web context","Pass an explicit user name when constructing DAOs directly instead of relying on ambient state","Use the shipped cli/*.php entry points, which initialize the user for you"],"exampleFix":"// before (custom script)\n$entryDAO = FreshRSS_Factory::createEntryDao(); // no active user -> throws\n\n// after\nMinz_User::change('alice');\n$entryDAO = FreshRSS_Factory::createEntryDao();","handlingStrategy":"validation","validationCode":"$user = Minz_User::name();\nif (!is_string($user) || $user === '') {\n\t// no user context: set one before any DAO is created\n\tMinz_User::change('alice');\n}\n$entryDAO = FreshRSS_Factory::createEntryDao();","typeGuard":"function hasCurrentUserContext(): bool {\n\t$name = Minz_User::name();\n\treturn is_string($name) && $name !== '';\n}","tryCatchPattern":"try {\n\t$dao = FreshRSS_Factory::createEntryDao();\n} catch (Minz_PDOConnectionException $e) {\n\tif (str_contains($e->getMessage(), 'Current user must not be empty')) {\n\t\t// bootstrap-order bug: initialize the user, then retry once\n\t\tMinz_User::change('alice');\n\t\t$dao = FreshRSS_Factory::createEntryDao();\n\t} else {\n\t\tthrow $e;\n\t}\n}","preventionTips":["In CLI scripts, call Minz_User::change($user) (or use the shipped cli/*.php entry points) before any DAO","Do not run extension hooks that hit the database before user initialization","Pass an explicit user name to DAO factories instead of relying on ambient state","Remember the guard is loose: an empty string fails the same as null"],"tags":["minz","database","pdo","user-context","bootstrap","cli"],"backgroundTag":"empty-current-user","analyzedSha":"95842d81c1b8ab673389544f072559aeb8cd7591","analyzedAt":"2026-08-23T00:21:00.265Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}