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

Cannot upload file when $grav['user'] is not set #352

Closed
AndruePeters opened this issue Jun 17, 2019 · 2 comments
Closed

Cannot upload file when $grav['user'] is not set #352

AndruePeters opened this issue Jun 17, 2019 · 2 comments

Comments

@AndruePeters
Copy link

AndruePeters commented Jun 17, 2019

Cannot upload file if $grav['user'] is not set.
Issue is on Grav 1.6.9 and 1.6.10. These are the only two versions I tested.

Fix is to change code in https://github.com/getgrav/grav-plugin-form/blob/develop/classes/Form.php on line 641 to

// We need to store the file into flash object or it will not be available upon save later on.
  $flash = $this->getFlash();
  if (isset($grav['user'])) {
    $flash->setUrl($url)->setUser($grav['user']);
  } else {
    $flash->setUrl($url);
  }

This also works:

$flash->setUrl($url)->setUser($grav['user'] ?? null);

This is with the fix:
Screen Shot 2019-06-17 at 1 39 49 PM

This is without the fix:
Screen Shot 2019-06-17 at 1 40 29 PM

I am not familiar with handling sessions with grav, but a comment in #332 says a session is needed. This works with system.session.enabled = false.
Also, is this maybe the issue for #349 ?

@rhukster
Copy link
Member

Looks like a decent fix.. @mahagr was working on some form updates recently related to flash storage, so be good for him to take a look.

@mahagr
Copy link
Member

mahagr commented Jun 26, 2019

Looks like I missed that one. Fixed now. I also found some other similar issues, will add checks against them, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants