"user@example.com") $username = substr($path, strlen('principals/')); // Create principal directly in database // Access protected pdo property from parent $pdo = $this->pdo; $tableName = $this->tableName; try { $stmt = $pdo->prepare( 'INSERT INTO ' . $tableName . ' (uri, email, displayname) VALUES (?, ?, ?) ON CONFLICT (uri) DO NOTHING' ); $stmt->execute([$path, $username, $username]); // Retry getting the principal $principal = parent::getPrincipalByPath($path); } catch (\Exception $e) { // If creation fails, return null error_log("Failed to auto-create principal: " . $e->getMessage()); return null; } } return $principal; } }