Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Standalone ZF2 forms: Captcha Dumb value is always wrong #22

Open
GeeH opened this issue Jun 28, 2016 · 1 comment
Open

Standalone ZF2 forms: Captcha Dumb value is always wrong #22

GeeH opened this issue Jun 28, 2016 · 1 comment

Comments

@GeeH
Copy link
Contributor

GeeH commented Jun 28, 2016

This issue has been moved from the zendframework repository as part of the bug migration program as outlined here - http://framework.zend.com/blog/2016-04-11-issue-closures.html


Original Issue: https://api.github.com/repos/zendframework/zendframework/issues/7098
User: @developer10
Created On: 2015-01-04T12:53:51Z
Updated At: 2015-01-05T10:27:52Z
Body
I first tried to use it without session at all but then included it like so:

$sessionManager = new Zend\Session\SessionManager();
$sessionManager->start();

After I enter the "word" my session outputs:

[Zend_Form_Captcha_0567fd5c45db3ad9136610ee3e10d71a] => Zend\Stdlib\ArrayObject Object
        (
            [storage:protected] => Array
                (
                    [word] => 74c74
                )

            [flag:protected] => 2
            [iteratorClass:protected] => ArrayIterator
            [protectedProperties:protected] => Array
                (
                    [0] => storage
                    [1] => flag
                    [2] => iteratorClass
                    [3] => protectedProperties
                )

        )

but the problem is that getMessages contains (see below) as if the word was entered incorrectly. I tried entering both backwards and normal way, the result is always the same: Captcha value is wrong

Array
(
    [captcha] => Array
        (
            [badCaptcha] => Captcha value is wrong
        )

)

Comment

User: @Ocramius
Created On: 2015-01-05T00:38:43Z
Updated At: 2015-01-05T00:38:43Z
Body
Requires an actual failing test case, I'd say. Session issues are always tricky to handle, therefore I suggest writing a small test.


Comment

User: @developer10
Created On: 2015-01-05T10:27:52Z
Updated At: 2015-01-05T10:27:52Z
Body
This may not be a bug or anything after all. I have put some print_r() in the class AbstractWord to see what the input value is actually compared to.

$this->id = $value['id'];
if ($input !== $this->getWord()) {

        echo '<pre>';
        print_r("Input: " . $input);
        print_r(" | getWord: " . $this->getWord());
        echo '</pre>';


        $this->error(self::BAD_CAPTCHA);
        return false;

The following happens:

The word is created, user inputs the value in the captcha field. But then when my form is submitted, a new request is being made so that the captcha input is actually being compared to the new word (from that subsequent request).

I assume I'm doing something incorrectly because I intentionally fill the other fields incorrectly and try to get the validation errors appear. They don't appear at all (maybe because of that new request; also my form is blank after that) and the only way I can see the errors is by outputting them below the form by calling echo on $form->getMessages().

Bearing in mind I'm implementing a standalone form and having a custom InputFilter class - why my form is submitting and the errors (including captcha one) are not appearing even though field values are incorrect?


@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-captcha; a new issue has been opened at laminas/laminas-captcha#4.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants