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

Serialization of 'Closure' is not allowed #522

Open
ravigupta112 opened this issue Mar 17, 2015 · 6 comments
Open

Serialization of 'Closure' is not allowed #522

ravigupta112 opened this issue Mar 17, 2015 · 6 comments

Comments

@ravigupta112
Copy link

When i submit the forgot password form i getting the "Serialization of 'Closure' is not allowed" Exceptio

after debugging i find the code from there error is reproduced

// File : confide/src/Confide/EloquentPasswordService.php

// Code:
protected function sendEmail($user, $token)
{
$config = $this->app['config'];
$lang = $this->app['translator'];

    $this->app['mailer']->queueOn(
        $config->get('confide::email_queue'),
        $config->get('confide::email_reset_password'),
        compact('user', 'token'),
        function ($message) use ($user, $token, $lang) {
            $message
                ->to($user->email, $user->username)
                ->subject($lang->get('confide::confide.email.password_reset.subject'));
        }
    );
} 
@Remo
Copy link

Remo commented Apr 23, 2015

did you ever find a solution to this problem?

@GrahamCampbell
Copy link
Contributor

did you ever find a solution to this problem?

Do $user->toArray() or something, but don't try to serialise the entire user object - that won't work.

@GrahamCampbell
Copy link
Contributor

It doesn't work because you end up trying to serialise the entire laravel service container and all resolved objects, lol.

@Remo
Copy link

Remo commented Apr 23, 2015

I'm just calling the password reset method.. will give you more details when I'm in front of a computer.

@Remo
Copy link

Remo commented Apr 24, 2015

@GrahamCampbell I'm only calling Confide::forgotPassword(Input::get('email')). Using version 4.2.

@Remo
Copy link

Remo commented Apr 24, 2015

I think this happens because $lang = $this->app['translator']; returns object(Polyglot\Services\Lang). It seems like polyglot can't be serialized that easily..

A workaround would be easy, I just replace the IoC with Lang::get to avoid polyglot and everything is fine, but that's not really what I want to do.

    protected function sendEmail($user, $token)
    {
        $config = $this->app['config'];

        $this->app['mailer']->queueOn(
            $config->get('confide::email_queue'),
            $config->get('confide::email_reset_password'),
            compact('user', 'token'),
            function ($message) use ($user, $token) {
                $message
                    ->to($user->email, $user->username)
                    ->subject(Lang::get('confide::confide.email.password_reset.subject'));
            }
        );
    }

Compare to: https://github.com/Zizaco/confide/blob/master/src/Confide/EloquentPasswordService.php#L169-L184

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