fix(expenses): read the upload's metadata before store() moves it away
This is the actual reason no receipt could be attached — 1b62a44f-… and
every other support code from the expense pages:
UnableToRetrieveMetadata: Unable to retrieve the file_size for file
at location: livewire-tmp/adbO73…jpg
ExpenseShow.php(93): TemporaryUploadedFile->getSize()
store() moves the file out of livewire-tmp. The attachment array put
'path' => $file->store(…) on its first line, and PHP evaluates array
literals in order, so getMimeType() and getSize() on the lines below ran
against a path that had just stopped existing. Validation passed, the
vanished-upload guard passed, the file was even written to its final
home — and then the request died with a 500 on the way to the row.
Nothing was ever saved.
Both handlers now read name, mime and size into locals first and store
last. Reproduced against a real local disk before and after; Livewire's
test harness swaps in a temp disk that does not move the file, which is
why a component test would have gone green on the broken code, so the
regression guard asserts the source ordering instead.
Co-Authored-By:
Claude Opus 5 (1M context) <noreply@anthropic.com>
Showing
Please register or sign in to comment