CakePHP Recaptcha plugin being called twice - cakephp

Well, i have been struggling this for almost a day now... Yet I cant figure out why my recaptcha plugin is being called twice. I suspect, my paypal plugin is also being called twice for sure. I really have no idea why my components are being called twice coz i know it is not possible for a plugin actions to be called twice if it is loaded twice. Any inputs/ideas will be highly appreciated. please help. I hate problems that don't give me much clues on where to look first. Thank you in advanced

I had this same problem. I noticed that reCAPTCHA was always failing validation and determined that it was being called twice and the second time always failed, I assume because the reCAPTCHA library is only designed to allow for a given challenge to be validated once.
In my case, it was being called twice because I was manually calling Model::validate() before Model::save(), which also validates unless if told not to. I fixed the issue by turning off validation in the call to save (Model::save(null, false)).

Related

Locking while front-end waits on response from backend

End users in our react application have the ability to make payments to loans via a pop up. The initial problem that we encountered is that users could click the pay button twice (or heaven forbid more than twice) and this would create multiple payments throwing our accounting into disarray. We thus implemented a sort of lock state that, when triggered to true, shows a loading gif displayed in a div with a simple tweak of the z-index. The state is passed down to the pop up from 2 components above. Every now and then I get an error message displaying that there is a possible memory leak. I assume this has something to do with my fix.
I'm just wondering, is there best practice on how to handle this sort of "locking" situation with react while waiting on some other external system to respond? I've tried to do this via the front-end but I'm not 100% convinced that it's the best and/or only solution.
If you need some code to better illustrate the scenario then let me know and I'll work on adding some examples.
Thanks in advance for your advice!
There's plenty of ways of doing this. You could even had multiple layers to the process. On top of layering the page using a z-indexed loading screen, you could also disable the button depending on some form of state change.
Also, the memory leak could be from you not disposing everything after the life cycle of a particular hook ends. I would suggest you look at using useEffect as a starting point. There's a good chance that either your modal or loading indicator is causing this. Often times, this can be fixed by adding a dependency array to useEffect. Obviously, I am making a lot of assumptions here.

What is the difference between browser.setLocation and browser.driver.get

I'm a protractor learner. So, I'm trying different methods in my tests while I'm testing my application. So, I was using browser.setLocation Before Each test for cases like page redirected during the test run, instead of just using browser.driver.get
As I understand I think using of browser.setLocation resolved lots of random failures I faced while running the test. I didn't want to use a browser.sleep().
I read this Protractor documentation for more clarification and it doesn't help.
Can someone tell me the usage of this method. Any kind of information will be appreciated.
Thanks in advance. :)
browser.setLocation() uses Angular's $location. browser.driver.get is like typing in a new URL into the search bar. browser.get, which is what most people use, is a wrapped version of browser.driver.get which waits for everything to be synced.

Debugging ng-click

I'm experiencing trouble with an angular-ui plugin (ui-select): for some reason, I cannot select any option.
Looking in dev tools and changing the ng-click attribute for the relevant DOM element to alert('test'); doesn't result in the alert being called either. This leads me to believe ng-click isn't being called for some reason.
Anyway, since I cannot find any information on this and I'm suspecting there might be a compatibility issue with another plugin or library. I'm wondering if there is any way that I can debug ng-click operations. I'd like to be able to pinpoint where in the event chain things go wrong.
There is a very useful post related to this post regarding why angular fails silently on errors in expressions
The work flow I have found to work for me is to first double check that your controller method or function that you are calling exists in your current scope. This can be a pain to debug, but often times I have found it's just a typo on my part.
I would start by putting debugger in the first line of that function or method and determining if your program haults there.
PS:
another explanation for this behavior
Load Chrome to your web site.
Press F12 for dev mode.
Go to Sources.
Set breakpoints in your JS files.

How to access a specific method within a class in Python

[Running Python 2.7 on MacOSX]
Hello there,
I've been struggling with this for a while now, and really need it sorted. If someone could write an example of how this possibly could be done, I would be really grateful.
Basically, what I am trying to do is access a specific method from within a class. So this class is being called from another file, so that this method can be called. However, I do not want any other method to be called, only this particular method.
I've tried to read through documentation to different posts around here. Still didn't find anything that seemed to help, perhaps I just don't grasp it very well. I'll look forward to suggestions - I will choose the best answer, I'm close to finishing what I'm working on but as it's an assignment I can't really post it here, and this is one of the last things stopping me.
Thank you in advance for any help!

Is it possible to 'deport' an imported controller in CakePHP?

I'm running into a problem with GroupsController::build_acl()- http://book.cakephp.org/view/647/An-Automated-tool-for-creating-ACOs
It's taken me a while to track down the bug and now I've found it I'm not sure how to work around it.
Symptoms:
Not all methods for NodesController (defined by me) are returned.
Probable reason:
build_acl() imports a 3rd party plugin that also has a NodesController and a subsequent App::import() doesn't overwrite it.
I'm about to try two runs of the build, one with the plugin code commented out, but a more durable solution would be preferred!
I need a way to either drop an imported controller or force a re-import while remaining in scope.
you can not do what you want to do, think about straight php for a while. once you have used include('some/file.php'); how do you un-import it? you cant.
now the reason why you cant overwrite it is once again down to php. what happens if you run
<?php
include('some/file.php');
include('some/file.php');
?>
you will get errors about the class being defined already.
Cake is stopping this from happening, so the only (and correct way) is to not have 2 controllers with the same name. you can name them what ever you like and use the router to map to nice urls.
Turns out the plugin was redundant and not called anywhere in the application and would have broken it if it was as a class redefinition error would have ensued. After removal of the files everything worked okay.

Resources