Skip to content

Multiple Issues with Cakephp 4.1 #19

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

Open
kujain opened this issue May 3, 2021 · 3 comments
Open

Multiple Issues with Cakephp 4.1 #19

kujain opened this issue May 3, 2021 · 3 comments

Comments

@kujain
Copy link

kujain commented May 3, 2021

I don't think the documentation is accurate for 4.1. I get errors with:

bin/cake plugin load -rb Recaptcha
Class 'Plugin' not found

if I add manually ($this->addPlugin('Recaptcha');), I get the following error on loading the form:

Helper class RecaptchaHelper could not be found.

Please help!

@kujain
Copy link
Author

kujain commented May 3, 2021

OK - with some hacking I was able to get the helper working in this way:
Controller:

        $this->loadComponent('Recaptcha.Recaptcha');
	$this->viewBuilder()->addHelper('Recaptcha.Recaptcha');
        .....
    	if ($this->request->is('post')) {
			if ($this->Recaptcha->verify()) {

View:

                    <?= $this->Recaptcha->display(); ?>

Now I see this error on submitting:

Call to a member function getData() on null
Error

  | public function verify()
  | {
  | $controller = $this->_registry->getController();
  | $gRecaptchaResponse = $controller->request->getData("g-recaptcha-response");
  | if (!empty($gRecaptchaResponse)) {
  |  
  | $resp = $this->recaptcha->verifyResponse(
  | new Client(),

There are also a number of warnings showing up like:

Deprecated (16384): notEmpty() is deprecated. Use notEmptyString(), notEmptyArray(), notEmptyFile(), notEmptyDate(), notEmptyTime() or notEmptyDateTime() instead. - //vendor/cakephp-fr/recaptcha/src/Validation/ConfigValidator.php, line: 29
 You can disable all deprecation warnings by setting `Error.errorLevel` to `E_ALL & ~E_USER_DEPRECATED`, or add `vendor/cakephp-fr/recaptcha/src/Validation/ConfigValidator.php` to  `Error.ignoredDeprecationPaths` in your `config/app.php` to mute deprecations from only this file. [CORE/src/Core/functions.php, line 316]
Deprecated (16384): `Validator::errors()` is deprecated. Use `Validator::validate()` instead. - /vendor/cakephp-fr/recaptcha/config/bootstrap.php, line: 20
 You can disable all deprecation warnings by setting `Error.errorLevel` to `E_ALL & ~E_USER_DEPRECATED`, or add `vendor/cakephp-fr/recaptcha/config/bootstrap.php` to  `Error.ignoredDeprecationPaths` in your `config/app.php` to mute deprecations from only this file. [CORE/src/Core/functions.php, line 316]
Notice (1024): Undefined property: AgenciesController::$request in //vendor/cakephp-fr/recaptcha/src/Controller/Component/RecaptchaComponent.php on line 87 [CORE/src/Controller/Controller.php, line 321]

Thanks!

@kujain
Copy link
Author

kujain commented May 3, 2021

I managed to make this work with a few edits to the core code as below:

RecaptchaComponent.php:
change line 14

use Cake\Http\Client;

change line :

        $gRecaptchaResponse = $controller->getRequest()->getData("g-recaptcha-response");

Recaptcha.php:
change line 87:

use Cake\Http\Client;

Could you please review and update if this fix is valid?
Thanks very much!

@wikosoft
Copy link

wikosoft commented May 8, 2021

Seems like this issue was fixed at this pull request: #13

And there's also an opened pull request to fix the deprecation errors for Validator::errors() here: #18

Not sure If cake17 is active

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

2 participants