Livewire 文件上传的多个问题

Livewire multiple issues with file upload

似乎是什么问题:

每次上传都会记录 6 个异常(尽管文件已上传)

重现步骤:

  1. 按照文档页面创建简单的文件上传
  2. 尝试上传文件
  3. 检查laravel 日志文件

Laravel版本:5.7

Livewire 版本:1.3.5

Laravel 日志样本:

[2021-01-21 11:05:07] local.ERROR:  {"userId":47,"email":"user@example.com","exception":"[object] (Exception(code: 0):  at /home/ameer/public_html/livewire.local/vendor/livewire/livewire/src/ComponentConcerns/HandlesActions.php:114)
[stacktrace]
#0 /home/ameer/public_html/livewire.local/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(755): Livewire\Component->Livewire\ComponentConcerns\{closure}()
#1 /home/ameer/public_html/livewire.local/vendor/livewire/livewire/src/ComponentConcerns/HandlesActions.php(121): rescue(Object(Closure), Object(Closure), false)
#2 [internal function]: Livewire\Component->Livewire\ComponentConcerns\{closure}(Object(ReflectionParameter), 0)
#3 /home/ameer/public_html/livewire.local/vendor/laravel/framework/src/Illuminate/Support/Collection.php(1034): array_map(Object(Closure), Array, Array)
#4 /home/ameer/public_html/livewire.local/vendor/livewire/livewire/src/ComponentConcerns/HandlesActions.php(122): Illuminate\Support\Collection->map(Object(Closure))
#5 /home/ameer/public_html/livewire.local/vendor/livewire/livewire/src/ComponentConcerns/HandlesActions.php(99): Livewire\Component->resolveActionParameters('startUpload', Array)
#6 /home/ameer/public_html/livewire.local/vendor/livewire/livewire/src/Connection/ConnectionHandler.php(46): Livewire\Component->callMethod('startUpload', Array)
...

调试后发现异常是由vendor/livewire/livewire/src/ComponentConcerns/HandlesActions.php

中的#111行引起的

我能够通过覆盖 livewire 组件文件中的 resolveActionParameters 方法来解决这个问题。

将方法更改为 return $params

的集合
protected function resolveActionParameters($method, $params)
{
    return collect($params);
}

到目前为止,这已经阻止了过多的异常记录,并且没有破坏任何 livewire 功能。