Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Request getIsLivePreview() not working #3680

Closed
putyourlightson opened this issue Jan 21, 2019 · 4 comments
Closed

Request getIsLivePreview() not working #3680

putyourlightson opened this issue Jan 21, 2019 · 4 comments

Comments

@putyourlightson
Copy link

putyourlightson commented Jan 21, 2019

The following appears to be returning false even in live preview requests (when it should obviously be returning true), which is tripping up the validation method in the Snaptcha plugin.

Craft::$app->getRequest()->getIsLivePreview()

This is happening as of Craft 3.1, currently seeing it on 3.1.2.2.

@putyourlightson
Copy link
Author

putyourlightson commented Jan 21, 2019

After some more investigating, it seems that it is working, but that the check is performed later than it was previously, so that it is not yet registered when the Controller::EVENT_BEFORE_ACTION event is triggered. If this is intentional then I'll update the code on my end.

@putyourlightson
Copy link
Author

If the line Craft::$app->getRequest()->setIsLivePreview(true); was moved from:
https://github.com/craftcms/cms/blob/3.1.2.2/src/controllers/LivePreviewController.php#L104
to:
https://github.com/craftcms/cms/blob/3.1.2.2/src/controllers/LivePreviewController.php#L36
then that would perhaps make it more reliable?

@brandonkelly
Copy link
Member

Yep, easy enough.

@putyourlightson
Copy link
Author

Thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant