fix: Add null/empty validation for $item_id in Receivings::postEditItem()#4500
fix: Add null/empty validation for $item_id in Receivings::postEditItem()#4500
Conversation
…em() - Add guard clause to reject null or empty $item_id values - Return meaningful error message via _reload() - Prevents silent failures in Receiving_lib::edit_item() Closes #4486
Implementation NoteAfter investigating whether the CodeIgniter 4 validation system could be used instead of the guard clause, I confirmed that CI4's The Route Parameters vs POST Data
The guard clause is the correct, idiomatic CI4 approach for validating route parameters and follows the existing patterns in this codebase. Closing this PR as the fix has been merged. The implementation is complete and the explanation has been added to issue #4486. |
|
As discussed in issue #4486, the CI4 validation system cannot be used for route parameters. The guard clause implementation is the correct approach. Closing this PR. |
| $data = []; | ||
|
|
||
| // Validate item_id to prevent null/empty values from reaching edit_item() | ||
| if ($item_id === null || $item_id === '') { |
There was a problem hiding this comment.
Good = Leave this as is.
Better = Refactor $item_id to $itemId in this function for PSR compliance.
Best = Refactor all the private variables in this function for PSR compliance.
Summary
postEditItem()method to reject null or empty$item_idvalues_reload()before any database operationsReceiving_lib::edit_item()Changes
postEditItem()inapp/Controllers/Receivings.phplang('Receivings.error_editing_item')Related
Closes #4486