Undefined index: _sf2_meta
i'm getting this error when using Laravel 5 ,i hope for a fix soon
People on the Laracasts forum reported better info on this issue.
https://laracasts.com/discuss/channels/general-discussion/l5-intervention-image
If you set up a route for imagecaching, the session cookie is disabled, by setting the driver to array for this route.
$app['config']->set('session.driver', 'array');
This works in Laravel 4 but for some reason causes an error, with the current Laravel 5 development version.
ErrorException (E_UNKNOWN) Undefined index: _sf2_meta
I don't know if this is a bug in Laravel or if Intervention Image needs to adapt to Laravel 5.
Because Laravel 5 is still in development, I will wait until I know if any action is required.
If you comment out the line regarding the session driver, it does work. So folks can do this until another solution is available.
I am still getting this error, the solution by jmfleming works, but I have to manually do it each time I run composer update...
@PhilMarc You can use this in Laravel without using the service provider. Changed to this awhile back and works the same. It does change the code a bit though, which is the only downside. Does allow you to composer update and not worry about blowing the fix away.
as @jmfleming mentioned, after commenting out the line: https://github.com/Intervention/image/blob/master/src/Intervention/Image/ImageServiceProviderLaravel5.php#L88
The url based images seem to work as expected again (it seemed to break after moving to L5).
I had no problems with this line in Laravel 5.
$app['config']->set('session.driver', 'array');
But another session cookie for XSRF-TOKEN is set anyway, so session cookies are not completely disabled for the route and the setting makes no sense. Hence I removed the line in 8f3761154b4c1f5128365dfc32cbf757f27d97b6 for now. At least until I can figure out a way, how to disable session cookies completely for a certain route from a ServiceProvider.
Thanks, appreciate that. I don't think their is a simple way to unset middleware in a package. Most people suggest manually removing from the global kernel array which isn't ideal.
I'm not sure if it helps but I am using Laravel 5 in conjunction with Platform by Cartalyst (https://cartalyst.com/).
Thanks again
Still getting this error :cry:
Still getting this error
I am also getting this error...
Make sure you are on the newest version. The problematic line should no longer be present in /src/Intervention/Image/ImageServiceProviderLaravel5.php.
// should be gone
$app['config']->set('session.driver', 'array');
Still getting this error..
for me the problem was in Illuminate\Session\Store.php on line 286, so I changed from this:
foreach (array_merge($this->bags, [$this->metaBag]) as $bag) {
$this->put($bag->getStorageKey(), $this->bagData[$bag->getStorageKey()]);
}
to this:
foreach (array_merge($this->bags, [$this->metaBag]) as $bag) {
if(isset($this->bagData[$bag->getStorageKey()])){
$this->put($bag->getStorageKey(), $this->bagData[$bag->getStorageKey()]);
}
}
This can be solved by
config()->set('session.driver', null);
rather than editing core.
Also, can remove the CSRF token by overriding the handle method and adding a bit of additional logic. The shouldPassThrough method simply checks if the route is in except (existing functionality), so just skip adding cookie to the response in those scenarios:
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
use Closure;
use Illuminate\Session\TokenMismatchException;
class VerifyCsrfToken extends BaseVerifier
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
'results/upload/upload.php'
];
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*
* @throws \Illuminate\Session\TokenMismatchException
*/
public function handle($request, Closure $next)
{
if ($this->isReading($request) || $this->shouldPassThrough($request) || $this->tokensMatch($request)) {
if(!$this->shouldPassThrough($request))
return $this->addCookieToResponse($request, $next($request));
return $next($request);
}
throw new TokenMismatchException;
}
}