evoWeb / recaptcha

TYPO3 Extension to make use of googles nocaptcha
GNU General Public License v2.0
6 stars 18 forks source link

translateErrorMessage argument error #6

Closed dahaupt closed 7 years ago

dahaupt commented 7 years ago

I'll try my best to describe the error, feel free to ask if something is not clear.

Bug

Oops, an error occurred!
Argument 2 passed to TYPO3\CMS\Form\Service\TranslationService::translateFormElementError() must be of the type integer, float given, called in C:\projects\myproject\vendor\typo3\cms\typo3\sysext\form\Classes\ViewHelpers\TranslateElementErrorViewHelper.php on line 72

Caused by This function in RecaptchaValidator.php:

public function isValid($value)
    {
        $captcha = \Evoweb\Recaptcha\Services\CaptchaService::getInstance();

        if ($captcha !== null) {
            $status = $captcha->validateReCaptcha();

            if ($status == false || $status['error'] !== '') {
                $this->addError(
                    $this->translateErrorMessage(
                        'error_recaptcha_' . $status['error'],
                        'recaptcha'
                    ),
                    1447258047591
                );
            }
        }
    }

The error is caused by the value 1447258047591, which is interpreted as a float value in my system. If I change the code to a lower value like 2 it's working again. Happens when using standard reCAPTCHA (not invisible) and not checking it.

I'm not informed about "standardized" Typo3 status codes or if I could just change that value, so I'm interested in your thoughts @garbast.

Edit: Maximum integer value on 32bit version of php is 2147483647.

System PHP 7.1.8 (cli) ( ZTS MSVC14 (Visual C++ 2015) x86 ) Windows 10 Pro XAMPP

garbast commented 7 years ago

32bit is long time gone. The number is the timestamp the message was created. A lot of developer tend to do so and the numbers wont get lower. So please consider updating your system.

To see if your machine is capable of running the extension please test the result of following script:

<?php
$t = 1447258047591;
var_dump($t);
// should result in int(1447258047591)

PHP 7.1.10-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Sep 29 2017 17:04:25) ( NTS )

dahaupt commented 7 years ago

@garbast Actually I am using XAMPP for development and there is no 64bit version 😞

I see what I can do to update manually to a 64bit version. My result of your test is float(1447258047591).