Drop app_local.php from production and show the mail transport in polls remind
CI / Deploy / PHP 8.4 (push) Successful in 1m11s
CI / Deploy / PHP 8.5 (push) Successful in 1m12s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped

app_local.php takes precedence over config/.env, so a copy made from an older
template forced the file transport and reminders never left the server.
Release package and Docker image now ship without it; app.php reads the
database from DATABASE_URL (SQLite default). app_local.example.php keeps
development defaults only. polls remind prints the transport and warns when
SMTP_HOST is set but SMTP is not used.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Sonnet 5.5 committed 2026-11-16 14:52:58 +01:00
1 parent f21aead039
commit 7fa33bbbdd
10 files changed
+65 -50

No files matched your search

+40
View File
@@ -9,6 +9,10 @@ use Cake\Console\Arguments;
use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOptionParser;
use Cake\I18n\DateTime;
use Cake\Mailer\Transport\SmtpTransport;
use Cake\Mailer\TransportFactory;
use ReflectionClass;
use function Cake\Core\env;
/**
* Mails the owners of polls that expire soon (POLL_REMINDER_DAYS before the end), once per poll.
@@ -82,6 +86,10 @@ class PollsRemindCommand extends PollsCommand
$due = $this->polls()->find('reminderDue')->orderBy(['Polls.id' => 'ASC'])->all()->toList();
}
if (!$dryRun && $due !== []) {
$io->out($this->describeTransport());
}
$sent = 0;
$failed = 0;
foreach ($due as $poll) {
@@ -116,4 +124,36 @@ class PollsRemindCommand extends PollsCommand
return $failed === 0 ? static::CODE_SUCCESS : static::CODE_ERROR;
}
/**
* One line about the mail transport in use (never the password), so a misconfiguration is visible at once.
*
* @return string
*/
protected function describeTransport(): string
{
$transport = TransportFactory::get('default');
$config = $transport->getConfig();
$class = (new ReflectionClass($transport))->getShortName();
if ($transport instanceof SmtpTransport) {
return __(
'Mail-Transport: {0} {1}:{2}, Benutzer {3}, TLS {4}',
$class,
$config['host'],
$config['port'],
$config['username'] ?? __('(keiner)'),
$config['tls'] ? __('ja') : __('nein'),
);
}
if (trim((string)env('SMTP_HOST', '')) !== '') {
return __(
'WARNUNG: SMTP_HOST ist gesetzt, aber der Transport ist {0}. Vermutlich überschreibt config/app_local.php ' .
'den Transport (auf Servern config/app_local.php löschen, Konfiguration nur über .env). Es wird nichts verschickt.',
$class,
);
}
return __('Mail-Transport: {0} (kein SMTP, SMTP_HOST nicht gesetzt)', $class);
}
}