From 72d390a9679a0d43e26a4a813dd37d768ce7d479 Mon Sep 17 00:00:00 2001 From: Eric Wasson <229096365+Eric-Wasson@users.noreply.github.com> Date: Wed, 18 Mar 2026 09:49:06 +0100 Subject: [PATCH 1/3] Moved display error handling to dockerfile --- Dockerfile | 5 +++-- ci/server/setup.php | 4 ---- src/api/v2/index.php | 2 +- src/inc/startup/include.php | 3 --- src/inc/startup/load.php | 3 --- src/inc/startup/setup.php | 3 --- 6 files changed, 4 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 77393a70d..84fc05343 100644 --- a/Dockerfile +++ b/Dockerfile @@ -122,7 +122,7 @@ RUN yes | pecl install xdebug && docker-php-ext-enable xdebug \ \ # Configuring PHP \ && touch "/usr/local/etc/php/conf.d/custom.ini" \ - && echo "display_errors = on" >> /usr/local/etc/php/conf.d/custom.ini \ + && echo "display_errors = 1" >> /usr/local/etc/php/conf.d/custom.ini \ && echo "memory_limit = 256m" >> /usr/local/etc/php/conf.d/custom.ini \ && echo "upload_max_filesize = 256m" >> /usr/local/etc/php/conf.d/custom.ini \ && echo "max_execution_time = 60" >> /usr/local/etc/php/conf.d/custom.ini \ @@ -163,7 +163,8 @@ RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \ && touch "/usr/local/etc/php/conf.d/custom.ini" \ && echo "memory_limit = 256m" >> /usr/local/etc/php/conf.d/custom.ini \ && echo "upload_max_filesize = 256m" >> /usr/local/etc/php/conf.d/custom.ini \ - && echo "max_execution_time = 60" >> /usr/local/etc/php/conf.d/custom.ini + && echo "max_execution_time = 60" >> /usr/local/etc/php/conf.d/custom.ini \ + && echo "display_errors = 0" >> /usr/local/etc/php/conf.d/custom.ini USER www-data # ----END---- diff --git a/ci/server/setup.php b/ci/server/setup.php index 46c93037a..8eb4b7911 100644 --- a/ci/server/setup.php +++ b/ci/server/setup.php @@ -38,7 +38,3 @@ fwrite(STDERR, "Failed to initialize database: " . $e->getMessage()); exit(-1); } - -$load = file_get_contents($envPath . "src/inc/startup/load.php"); -$load = str_replace('ini_set("display_errors", "0");', 'ini_set("display_errors", "1");', $load); -file_put_contents($envPath . "src/inc/startup/load.php", $load); diff --git a/src/api/v2/index.php b/src/api/v2/index.php index 668eb0054..40731655c 100644 --- a/src/api/v2/index.php +++ b/src/api/v2/index.php @@ -8,7 +8,7 @@ date_default_timezone_set("UTC"); error_reporting(E_ALL ^ E_DEPRECATED); -ini_set("display_errors", '1'); + /** * Treat warnings as error, very useful during unit testing. * TODO: How-ever during Xdebug debugging under VS Code, this is very diff --git a/src/inc/startup/include.php b/src/inc/startup/include.php index 807b492d5..71bd49b74 100755 --- a/src/inc/startup/include.php +++ b/src/inc/startup/include.php @@ -1,10 +1,7 @@ Date: Wed, 18 Mar 2026 10:55:32 +0100 Subject: [PATCH 2/3] Fixed faq and tests --- doc/faq_tips/faq.md | 3 ++- src/inc/Util.php | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/faq_tips/faq.md b/doc/faq_tips/faq.md index ce50884fc..110d4b560 100644 --- a/doc/faq_tips/faq.md +++ b/doc/faq_tips/faq.md @@ -303,7 +303,7 @@ If there is enough RAM available, it is possible to raise PHP's memory limit in 1. **Create a file `custom.ini` next to your `docker-compose.yml`** Adjust your desired memory limit (`M` for Megabytes, or `G` for Gigabytes). - The other two values are optional to adjust, but need to remain in there, as otherwise they are overwritten with the new `custom.ini` not containing them. + The other three values are optional to adjust, but need to remain in there, as otherwise they are overwritten with the new `custom.ini` not containing them. ```ini @@ -311,6 +311,7 @@ If there is enough RAM available, it is possible to raise PHP's memory limit in memory_limit = 256M upload_max_filesize = 256M max_execution_time = 60 +display_errors = 0 ``` diff --git a/src/inc/Util.php b/src/inc/Util.php index e5597293e..e899be49d 100755 --- a/src/inc/Util.php +++ b/src/inc/Util.php @@ -1371,9 +1371,12 @@ public static function sendMail($address, $subject, $text, $plaintext) { $htmlMessage .= $text; $htmlMessage .= "\r\n\r\n--" . $boundary . "--"; + set_error_handler(function() { error_log("Error sending mail"); }); if (!mail($address, $subject, $plainMessage . $htmlMessage, $headers)) { + restore_error_handler(); return false; } + restore_error_handler(); return true; } From b4bcdc6e7225e8029bc51e49bc53a5a1b4186077 Mon Sep 17 00:00:00 2001 From: Eric Wasson <229096365+Eric-Wasson@users.noreply.github.com> Date: Wed, 18 Mar 2026 11:29:54 +0100 Subject: [PATCH 3/3] Fixed array error --- src/inc/apiv2/common/AbstractModelAPI.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/inc/apiv2/common/AbstractModelAPI.php b/src/inc/apiv2/common/AbstractModelAPI.php index 2e90471ab..e5de681bb 100644 --- a/src/inc/apiv2/common/AbstractModelAPI.php +++ b/src/inc/apiv2/common/AbstractModelAPI.php @@ -740,7 +740,7 @@ public static function getManyResources(object $apiClass, Request $request, Resp $primary_cursor_key = key($primary_cursor); // Special filtering of id to use for uniform access to model primary key $primary_cursor_key = $primary_cursor_key == 'id' ? array_column($aliasedfeatures, 'alias', 'dbname')[$apiClass->getPrimaryKey()] : $primary_cursor_key; - $secondary_cursor = $decoded_cursor["secondary"]; + $secondary_cursor = array_key_exists("secondary", $decoded_cursor) ? $decoded_cursor["secondary"] : null; if ($secondary_cursor) { $secondary_cursor_key = key($secondary_cursor); $secondary_cursor_key = $secondary_cursor_key == '_id' ? array_column($aliasedfeatures, 'alias', 'dbname')[$apiClass->getPrimaryKey()] : $secondary_cursor_key;