From 2c879e6b5789d2c48c7caecd170a3512445da05b Mon Sep 17 00:00:00 2001 From: Avatarsia Date: Thu, 2 Apr 2026 00:29:55 +0200 Subject: [PATCH] fix: POST /v1/dateien stichwoerter variable scoping bug (#245) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit $stichwoerter was only initialized inside the if-block but used in the foreach outside it. When stichwoerter were not provided or not an array, the variable was undefined — causing the foreach to silently skip (masked by error_reporting(E_ERROR) in api/index.php). Also added isset() check to prevent PHP Notice on missing key. Fixes: https://github.com/OpenXE-org/OpenXE/issues/245 --- classes/Modules/Api/Controller/Version1/FileController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/Modules/Api/Controller/Version1/FileController.php b/classes/Modules/Api/Controller/Version1/FileController.php index ad88cc26e..9fab4c484 100644 --- a/classes/Modules/Api/Controller/Version1/FileController.php +++ b/classes/Modules/Api/Controller/Version1/FileController.php @@ -124,8 +124,8 @@ public function createAction() throw new BadRequestException('Required property "file_content" is missing.'); } - if (is_array($input['stichwoerter'])) { - $stichwoerter = array(); + $stichwoerter = array(); + if (isset($input['stichwoerter']) && is_array($input['stichwoerter'])) { $erp = $this->legacyApi->app->erp; $DB = $this->legacyApi->app->DB; foreach ($input['stichwoerter'] as $stichwort_input) {