Moved database methods into own context class.

This commit is contained in:
flash 2025-02-09 17:39:48 +00:00
parent 21a730d189
commit bac889787a
14 changed files with 94 additions and 62 deletions
public-legacy
auth
forum
manage/users
settings

View file

@ -114,6 +114,8 @@ while($canResetPassword) {
} catch(RuntimeException $ex) {
$tokenInfo = $msz->authCtx->recoveryTokens->createToken($forgotUser, $ipAddress);
$msz->initMailer();
$recoveryMessage = Mailer::template('password-recovery', [
'username' => $forgotUser->name,
'token' => $tokenInfo->code,

View file

@ -153,7 +153,7 @@ if(!empty($_POST)) {
$isEditingTopic = empty($topicInfo) || ($mode === 'edit' && $originalPostInfo->id == $postInfo->id);
if($mode === 'create') {
$postTimeout = $cfg->getInteger('forum.posting.timeout', 5);
$postTimeout = $msz->config->getInteger('forum.posting.timeout', 5);
if($postTimeout > 0) {
$postTimeoutThreshold = new CarbonImmutable(sprintf('-%d seconds', $postTimeout));
$lastPostCreatedAt = $msz->forumCtx->posts->getUserLastPostCreatedAt($currentUser);
@ -173,7 +173,7 @@ if(!empty($_POST)) {
$originalTopicType = $topicInfo?->typeString ?? 'discussion'; // @phpstan-ignore-line: this also
$topicTypeChanged = $topicType !== null && $topicType !== $originalTopicType;
$topicTitleLengths = $cfg->getValues([
$topicTitleLengths = $msz->config->getValues([
['forum.topic.minLength:i', 3],
['forum.topic.maxLength:i', 100],
]);
@ -191,7 +191,7 @@ if(!empty($_POST)) {
}
}
$postTextLengths = $cfg->getValues([
$postTextLengths = $msz->config->getValues([
['forum.post.minLength:i', 1],
['forum.post.maxLength:i', 60000],
]);

View file

@ -81,6 +81,7 @@ if(CSRF::validateRequest() && $canEdit) {
} elseif(!is_string($_POST['send_test_email']) || $_POST['send_test_email'] !== 'yes_send_it') {
$notices[] = 'Invalid request thing shut the fuck up.';
} else {
$msz->initMailer();
$testMail = Mailer::sendMessage(
[$userInfo->emailAddress => $userInfo->name],
'Flashii Test E-mail',

View file

@ -11,7 +11,7 @@ if(!isset($msz) || !($msz instanceof \Misuzu\MisuzuContext))
if(!$msz->authInfo->loggedIn)
Template::throwError(401);
$dbConn = $msz->dbConn;
$dbConn = $msz->dbCtx->conn;
/** @param string[] $fieldInfos */
function db_to_zip(