Draft: Add Model\Account class to handle accounts
This is a rather large set of patches, that add an Account
model to handle all interactions with the accounts
database table. This will hopefully make it a bit easier to reason about where account information is modified, instead of having direct database queries spread throughout the code.
The idea is also that this will be a model for turning other database table objects into model objects.
The following modules have been updated to use the new API:
Zotlabs\Lib\Libzot::site_info
Zotlabs\Module\Admin\Account_edit
Zotlabs\Module\Regate
For the Account_edit
module, this also includes significantly improved input validation, and refactoring to make the code more robust and simpler.
I've also marked the following functions from include/account.php
as deprecated:
-
get_account_by_id
: Replaced byZotlabs\Model\Account::get_by_id()
. -
account_total
: Replaced byZotlabs\Model\Account::count()
As there's still code (and potentially addons) that use these functions, we can't just remove them cold quite yet.
Note that Zotlabs\Model\Account::get_by_id()
returns an Account
object, not an associative array of key/value pairs. This allows for better type checking and moving the type checking to the class, instead of spread around and repeated throughout the code base.
This patch also fixes #1876 (CVE-2024-51443).