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

can't write session on controller issue on 2.0.15.1 #16959

Closed
ash-rwt opened this issue Dec 10, 2018 · 14 comments
Closed

can't write session on controller issue on 2.0.15.1 #16959

ash-rwt opened this issue Dec 10, 2018 · 14 comments

Comments

@ash-rwt
Copy link

ash-rwt commented Dec 10, 2018

So, I upgraded Yii Framework from version 2.0.12 to 2.0.15.1 and now i am facing session writing issue which was working fine on 2.0.12.
For example -
$session = \Yii::$app->session;
$session['filter'] = [
'filter_dealer' => 4,
];

Doesn't work which was working fine before i upgraded framework.
Permissions are correct. Also, tried to switching session from memcached to filecache and vice versa but didn't work.

UPDATE :
Its issue with yii\web\DbSession. Works fine with default yii\web\CacheSession

@samdark samdark added type:bug Bug status:to be verified Needs to be reproduced and validated. status:need more info labels Dec 11, 2018
@samdark samdark added this to the 2.0.16 milestone Dec 11, 2018
@yii-bot
Copy link

yii-bot commented Dec 11, 2018

Thanks for posting in our issue tracker.
In order to properly assist you, we need additional information:

  • When does the issue occur?
  • What do you see?
  • What was the expected result?
  • Can you supply us with a stacktrace? (optional)
  • Do you have exact code to reproduce it? Maybe a PHPUnit tests that fails? (optional)

Thanks!

This is an automated comment, triggered by adding the label status:need more info.

@samdark
Copy link
Member

samdark commented Dec 11, 2018

How's your session configured?

@ash-rwt
Copy link
Author

ash-rwt commented Dec 11, 2018 via email

@samdark
Copy link
Member

samdark commented Dec 12, 2018

Which database is used?

@ash-rwt
Copy link
Author

ash-rwt commented Dec 18, 2018

Mysql

@samdark
Copy link
Member

samdark commented Dec 30, 2018

Anything in logs?

@machour
Copy link
Member

machour commented Jan 14, 2019

@ashishrawat417 anything new about this issue? We'd like to sort this out before releasing 2.0.16.
Thank you!

@schmunk42
Copy link
Contributor

@ashishrawat417 Do you have multiple requests (eg. AJAX) which might overwrite their session data?

@talentant
Copy link
Contributor

talentant commented Jan 15, 2019

Hi guys, I may have found this bug...

commit: d165863

code line: https://github.com/yiisoft/yii2/blob/master/framework/web/DbSession.php#L224


is_array($fields['data'] && is_object($fields['data']))

it will always return false

@talentant
Copy link
Contributor

And I think the method DbSession::typecastFields should be tested by unit tests.

    /**
     * Method typecasts $fields before passing them to PDO.
     * Default implementation casts field `data` to `\PDO::PARAM_LOB`.
     * You can override this method in case you need special type casting.
     *
     * @param array $fields Fields, that will be passed to PDO. Key - name, Value - value
     * @return array
     * @since 2.0.13
     */
    protected function typecastFields($fields)
    {
        ...

        return $fields;
    }

@samdark
Copy link
Member

samdark commented Jan 15, 2019

@SilverFire would you please take a look?

@SilverFire
Copy link
Member

@talentant thank you, the condition was obviously broken. I've fixed it and added test that checks that session override works, but it works even before my fix in DbSession.

@ashishrawat417 could you, please, check if patched worked for you and adjust test if it still does not work for you?

@SilverFire SilverFire removed the status:to be verified Needs to be reproduced and validated. label Jan 15, 2019
@samdark samdark closed this as completed Jan 15, 2019
@samdark
Copy link
Member

samdark commented Jan 15, 2019

Closing assuming it's fixed now.

@samdark
Copy link
Member

samdark commented Jan 15, 2019

@ashishrawat417 please checking when you have a chance.

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

7 participants