silverstripe / silverstripe-mathspamprotection

BSD 3-Clause "New" or "Revised" License
19 stars 20 forks source link

Userforms 3.x fix #42

Closed tazzydemon closed 3 years ago

tazzydemon commented 8 years ago

Something has changed in the object flow in the current Framework 3.2 / UserForms 3.x combination.

$this inside the MathSpamProtectorField object during validation now contains no references to the current controller. $this->Value returns null and thus line 82 fails:

L82 if (!self::correct_answer($this->Value())) {

I propose a change thus:

L82 if (!self::correct_answer(Controller::curr()->getRequest()->postVar($this->getName()))) {

This change makes UserForms 3 work. YMMV, UserForms 3 still returns a junk message based on field name as opposed to the return message. This is alterable and I will try to fix that up too.

guyvanbael commented 8 years ago

@tazzydemon this change in L82 indeed fixed the issue. I hope it will be added to the core code. thanks again for looking into it!!!!

tazzydemon commented 8 years ago

I have altered some some code in Silverstripe Spamprotection now too... have a look at https://github.com/silverstripe/silverstripe-spamprotection/issues/39#issuecomment-162352476

I guess I might have to fork and request a pull, so if you test this and say its OK please let me know. The problem is that I'm not really interested in running all the required text fixtures (I've never learned them and I'm getting too old!!)