FreshRSS/FreshRSS · error · Minz_PDOConnectionException
0
0
Error message
Current user must not be empty!
What it means
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.
Source
Thrown at lib/Minz/ModelPdo.php:115
/**
* Create the connection to the database using the variables
* HOST, BASE, USER and PASS variables defined in the configuration file
* @throws Minz_ConfigurationException
* @throws Minz_PDOConnectionException
*/
public function __construct(?string $currentUser = null, ?Minz_Pdo $currentPdo = null) {
if ($currentUser === null) {
$currentUser = Minz_User::name();
}
if ($currentPdo !== null) {
$this->pdo = $currentPdo;
return;
}
if (self::$dummyConnection) {
return;
}
if ($currentUser == null) {
throw new Minz_PDOConnectionException('Current user must not be empty!', '', Minz_Exception::ERROR);
}
if (self::$usesSharedPdo && self::$sharedPdo !== null && $currentUser === self::$sharedCurrentUser) {
$this->pdo = self::$sharedPdo;
$this->current_user = self::$sharedCurrentUser;
return;
}
$this->current_user = $currentUser;
if (self::$usesSharedPdo) {
self::$sharedCurrentUser = $currentUser;
}
$ex = null;
//Attempt a few times to connect to database
for ($attempt = 1; $attempt <= 5; $attempt++) {
try {
$this->dbConnect();
return;
} catch (PDOException $e) {View on GitHub (pinned to 95842d81c1)
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
Example fix
// before (custom script)
$entryDAO = FreshRSS_Factory::createEntryDao(); // no active user -> throws
// after
Minz_User::change('alice');
$entryDAO = FreshRSS_Factory::createEntryDao(); Defensive patterns
Strategy: validation
Validate before calling
$user = Minz_User::name();
if (!is_string($user) || $user === '') {
// no user context: set one before any DAO is created
Minz_User::change('alice');
}
$entryDAO = FreshRSS_Factory::createEntryDao(); Type guard
function hasCurrentUserContext(): bool {
$name = Minz_User::name();
return is_string($name) && $name !== '';
} Try / catch
try {
$dao = FreshRSS_Factory::createEntryDao();
} catch (Minz_PDOConnectionException $e) {
if (str_contains($e->getMessage(), 'Current user must not be empty')) {
// bootstrap-order bug: initialize the user, then retry once
Minz_User::change('alice');
$dao = FreshRSS_Factory::createEntryDao();
} else {
throw $e;
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Custom cron/console scripts that include FreshRSS bootstrap constants but forget the user; extensions running early hook code before user setup; partially bootstrapped contexts.
Related errors
- Invalid database type!
- Invalid PDO driver behaviour for selected database type!
- {$version} migration does not exist.
- Controller not found!
- Invalid action name “{action_name}” for controller “{control
AI-assisted analysis of FreshRSS/FreshRSS@95842d81c1 (2026-08-23).
Data as JSON: /api/errors/381397bcd4e3e021.
Report an issue: GitHub.