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

Call to a member function validateCsrfToken() on string #18154

Closed
aliabdzad opened this issue Jul 5, 2020 · 12 comments
Closed

Call to a member function validateCsrfToken() on string #18154

aliabdzad opened this issue Jul 5, 2020 · 12 comments

Comments

@aliabdzad
Copy link

aliabdzad commented Jul 5, 2020

i have a problem after ((Controller::$request and $response)) change
in beforeAction when we print (( $this->validateCsrfToken() )) it returns : 'request' not an object
it seems $this->validateCsrfToken() has not the same value as Yii::$app->getRequest()->validateCsrfToken()
and this problem stops my controllers
please resolve this

Additional info

Q A
Yii version 2.0.15
PHP version 7.2
Operating system centos
@alex-code
Copy link
Contributor

Can you confirm which version you are on?
Latest Yii2 is 2.0.35 which is 20 releases ahead of the one you listed.

If you are on .15 can you update to .35 and test again.

@yiisoft yiisoft deleted a comment from yii-bot Jul 5, 2020
@aliabdzad
Copy link
Author

Can you confirm which version you are on?
Latest Yii2 is 2.0.35 which is 20 releases ahead of the one you listed.

If you are on .15 can you update to .35 and test again.

updated to .35 but still the same error

@samdark
Copy link
Member

samdark commented Jul 5, 2020

Would you please provide full error message including file, line and stracktrace?

@aliabdzad
Copy link
Author

aliabdzad commented Jul 6, 2020

Would you please provide full error message including file, line and stracktrace?

Screenshot (364)

@alex-code
Copy link
Contributor

Do you have an init(); in your SiteController?

If so you need to call parent::init();

@aliabdzad
Copy link
Author

Do you have an init(); in your SiteController?

If so you need to call parent::init();

true, it seems solved
thanks

@tarx1234
Copy link

I have the same issue, but my SiteController doesn't have an init();
I'm running Yii2 version 2.0.36
Is there another way to solve this issue or do I need to add an init(); function and call parent::init(); in there?

@alex-code
Copy link
Contributor

Does your SiteController extend from another custom Controller class?

@tarx1234
Copy link

Yes. I have just found what my issue was. Thank you.

@xstnet
Copy link

xstnet commented Aug 4, 2020

Do you have an init(); in your SiteController?

If so you need to call parent::init();

I upgraded from 2.015 to 2.0.35 and also had this problem

Thanks, that solves my problem

@konellemhs
Copy link

konellemhs commented Oct 5, 2020

I upgraded from 2.015 to 2.0.35 and also had this problem
Also i tried to call the method init() and and it doesn't work either(
Can anyone help me?

@bizley
Copy link
Member

bizley commented Oct 5, 2020

Please use the Forum if you have any questions.

@yiisoft yiisoft locked as resolved and limited conversation to collaborators Oct 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants