fix: POST /v1/dateien stichwoerter variable scoping bug (#245)#246
Open
Avatarsia wants to merge 1 commit intoOpenXE-org:masterfrom
Open
fix: POST /v1/dateien stichwoerter variable scoping bug (#245)#246Avatarsia wants to merge 1 commit intoOpenXE-org:masterfrom
Avatarsia wants to merge 1 commit intoOpenXE-org:masterfrom
Conversation
$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: OpenXE-org#245
Avatarsia
pushed a commit
to Avatarsia/OpenXE
that referenced
this pull request
Apr 9, 2026
All four are single-file Avatarsia-authored bug fixes that are also open upstream PRs on openxe-org: - fix/250-wiedervorlage-sidebar-counter (PR OpenXE-org#253) www/eproosystem.php +2/-2: reactivate Wiedervorlagen counter - fix/dateien-stichwoerter-245 (PR OpenXE-org#246) classes/Modules/Api/Controller/Version1/FileController.php +2/-2: fix variable scoping in POST /v1/dateien stichwoerter - fix/versandpakete-247 (PR OpenXE-org#248) classes/Modules/Api/Controller/Version1/TrackingNumberController.php +25: write tracking numbers into the versandpakete table so the UI shows them - fix/player-custom-module-support (PR OpenXE-org#256) phpwf/class.player.php +12/-2: support _custom.php extension files for page controllers, analogous to class.erpapi_custom.php Each branch is based on an older origin/master snapshot, but since origin/master is strictly behind upstream/master (zero divergent commits), git merges only the new commits during integration without re-applying the upstream drift.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FileController::createAction()where$stichwoerterwas only initialized inside theif-block but used in theforeachoutside itisset()check to prevent PHP Notice on missing array keyProblem
When uploading files via
POST /v1/dateienwithstichwoerterparameters for object binding (e.g. attaching a file to an Auftrag), the stichwoerter are silently ignored. The file is created but without any object association. Files created through the PHP UI work correctly.Root Cause
$stichwoerter = array()was defined on line 128 inside theif (is_array(...))block, but theforeach ($stichwoerter as ...)on line 176 runs outside that block. When theifcondition is false,$stichwoerteris undefined. The resulting PHP Warning is masked byerror_reporting(E_ERROR)inwww/api/index.php.Fix (2 lines changed)
Test plan
datei_stichwoertertable entry createdFixes #245