From 5882e9745eed09d8f7a0b47917134f4567e3dbbd Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Tue, 24 Feb 2026 02:09:12 +0100 Subject: [PATCH] fer --- src/ApiKernel.php | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/ApiKernel.php b/src/ApiKernel.php index 7b2a276..5ef6fc3 100755 --- a/src/ApiKernel.php +++ b/src/ApiKernel.php @@ -2357,7 +2357,11 @@ class ApiKernel 'html_length' => strlen($html), 'mail_error' => $this->lastMailError, ]); - $this->fail('Send failed', null, 500); + $detail = null; + if ($this->isStagingEnv()) { + $detail = ['mail_error' => $this->lastMailError]; + } + $this->fail('Send failed', $detail, 500); } if ($customerId > 0) { @@ -5816,20 +5820,8 @@ SQL; private function writeDebugLog(string $name, array $payload): void { - $env = strtolower((string)($this->conf['env'] ?? '')); - if ($env !== 'staging' && (!defined('APP_ENV') || strtolower((string)APP_ENV) !== 'staging')) { - $host = ''; - if (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { - $host = strtolower(trim(explode(',', (string)$_SERVER['HTTP_X_FORWARDED_HOST'])[0])); - } elseif (!empty($_SERVER['HTTP_HOST'])) { - $host = strtolower((string)$_SERVER['HTTP_HOST']); - } - if ($host !== '') { - $host = preg_replace('/:\\d+$/', '', $host); - } - if ($host !== 'staging.emailtemplate.it') { - return; - } + if (!$this->isStagingEnv()) { + return; } $dir = $this->debugDir(); debug_log_write($name, $payload, [ @@ -5840,6 +5832,23 @@ SQL; ]); } + private function isStagingEnv(): bool + { + $env = strtolower((string)($this->conf['env'] ?? '')); + if ($env === 'staging') return true; + if (defined('APP_ENV') && strtolower((string)APP_ENV) === 'staging') return true; + $host = ''; + if (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { + $host = strtolower(trim(explode(',', (string)$_SERVER['HTTP_X_FORWARDED_HOST'])[0])); + } elseif (!empty($_SERVER['HTTP_HOST'])) { + $host = strtolower((string)$_SERVER['HTTP_HOST']); + } + if ($host !== '') { + $host = preg_replace('/:\\d+$/', '', $host); + } + return $host === 'staging.emailtemplate.it'; + } + private function defaultApiBase(): string { $base = $this->conf['base_url'] ?? '';