Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Troubles after new implementation filterFiles #15556

Closed
chamav opened this issue Sep 22, 2016 · 4 comments
Closed

Troubles after new implementation filterFiles #15556

chamav opened this issue Sep 22, 2016 · 4 comments

Comments

@chamav
Copy link

chamav commented Sep 22, 2016

  • Laravel Version: 5.3.10
  • PHP Version: 7.0.10
  • Database Driver & Version:

Description:

after last changes sometimes we have the error in

class Request extends SymfonyRequest implements Arrayable, ArrayAccess
/**
     * Filter the given array of files, removing any empty values.
     *
     * @param  array  $files
     * @return mixed
     */
    protected function filterFiles($files)
    {
        foreach ($files as $key => $file) {
            if (is_array($file)) {
                $files[$key] = $this->filterFiles($files[$key]);
            }

            if (empty($files[$key])) {
                unset($files[$key]);
            }
        }

        return $files;
    }

vendor/laravel/framework/src/Illuminate/Http/Request.php:878
Invalid argument supplied for foreach()

incorrect work method duplicates in class Request

/**
     * {@inheritdoc}
     */
    public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null)
    {
        return parent::duplicate($query, $request, $attributes, $cookies, $this->filterFiles($files), $server);
    }

because variable $files by default is null
I think that need to change input parameters on $files = []
or add checks to filterFiles file

Steps To Reproduce:

if i used $request->instance()->duplicate() then i receive error

vendor/laravel/framework/src/Illuminate/Http/Request.php:878
Invalid argument supplied for foreach()

@themsaid
Copy link
Member

themsaid commented Sep 22, 2016

Interested to know why you would use $request->instance()->duplicate().

@chamav
Copy link
Author

chamav commented Sep 22, 2016

I used batch-request library used for union few api methods in one batch
https://packagist.org/packages/optimus/batch-request

https://github.com/esbenp/laravel-api-consumer/blob/master/src/Router.php
string 117
In my opinion, it is no mistake of library

@themsaid
Copy link
Member

Yeah, submitted a fix. Thank you for the report :)

#15558

@chamav
Copy link
Author

chamav commented Sep 22, 2016

Thank you very mach!

@chamav chamav closed this as completed Sep 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants