# |
Feb 8th 2018, 19:21 |
kevin |
I cant seem to find anything to specifically assist with that |
# |
Feb 8th 2018, 19:21 |
kevin |
cake 3.5 |
# |
Feb 8th 2018, 19:21 |
kevin |
Is anyone aware of a good guide on how to perform data validation on a signup page, including verifying whether a user already exists or not? |
# |
Feb 8th 2018, 18:47 |
sayed |
thanks once again ! |
# |
Feb 8th 2018, 18:46 |
sayed |
no it is exactly what i needed |
# |
Feb 8th 2018, 18:46 |
hmic |
if it's not perfectly up to your case, you get at least a bunch of ideas |
# |
Feb 8th 2018, 18:46 |
hmic |
but throttle is the thing to look into |
# |
Feb 8th 2018, 18:46 |
hmic |
thats why i asked ;-) |
# |
Feb 8th 2018, 18:45 |
sayed |
wrong term |
# |
Feb 8th 2018, 18:45 |
sayed |
oke sure my bad |
# |
Feb 8th 2018, 18:45 |
sayed |
Thanks guys |
# |
Feb 8th 2018, 18:45 |
hmic |
which is stupid. especially for a webserver |
# |
Feb 8th 2018, 18:45 |
hmic |
not "block concurrent" |
# |
Feb 8th 2018, 18:45 |
hmic |
yeah. throttle |
# |
Feb 8th 2018, 18:44 |
sayed |
Wel lets say i have an Api with an Endpoint, the client who is trying to submit data has a ‘retry mechanism’ which just goes crazy, so my log files are over 6 mb in like a couple of minutes. So basically i would like to block them after 200+ requests from which they get denied |
# |
Feb 8th 2018, 18:44 |
bravo-kernel |
@sayed https://github.com/UseMuffin/Throttle |
# |
Feb 8th 2018, 18:42 |
hmic |
why would you want that? |
# |
Feb 8th 2018, 18:42 |
sayed |
Guys, anyone with a good idea on how to block concurrent requests to the server, with cake of course. |
# |
Feb 8th 2018, 17:59 |
pedroseco |
ok só um probably doing something wrong on my "listen" part |
# |
Feb 8th 2018, 17:51 |
hmic |
and thats all you need to do. listen to the event you emit. does not matter which plugin or app does what exactly. just match the events name and make sure to listen before emitting it (and the correct eventmanager is involved, usually go for the global one and attach early (bootstrap.php)) |
# |
Feb 8th 2018, 17:49 |
hmic |
pedroseco: you dont access events, you listen to them |
# |
Feb 8th 2018, 17:37 |
pedroseco |
what's the best way to share a callback from a event between all my plugins? Ex acessing from PLugin X a particular event emitted by Plugin Y |
# |
Feb 8th 2018, 16:52 |
jotpe |
I tried something like `$this->assertResponseFailure($result = $this->Flash->render('custom5'));` but phpunit just tells me, that there was an error ;) |
# |
Feb 8th 2018, 16:51 |
jotpe |
Hey guys! How can i write a Test, if a method rises a UnexpectedValueException? |
# |
Feb 8th 2018, 16:46 |
spencdev |
What doesn’t lol. I’m fighting with the 7.1 tempnam notices |
# |
Feb 8th 2018, 16:39 |
neon1024 |
Nah, I’m using multidimensional arrays which upsets PHP apparently |
# |
Feb 8th 2018, 16:38 |
spencdev |
When you use their example? |
# |
Feb 8th 2018, 16:33 |
neon1024 |
Then you get, `: Indirect modification of overloaded element of ArrayObject has no effect [` |
# |
Feb 8th 2018, 16:33 |
neon1024 |
`The $data parameter is an ArrayObject instance, so you don't have to return it to change the data used to create entities.` |
# |
Feb 8th 2018, 16:33 |
neon1024 |
I like the docs stating this, https://book.cakephp.org/3.0/en/orm/saving-data.html#modifying-request-data-before-building-entities |
# |
Feb 8th 2018, 16:32 |
spencdev |
Another way, and it could quite possibly be really bad advice, is to use Events. As a last ditch effort to kind of duct tape it together, you could make an event and in your non-plugin model/controller have it fire an event to check if everything saved properly. That may be over engineering something, and like I said, could quite possibly be really bad advice. Take it for what its worth. |
# |
Feb 8th 2018, 16:29 |
spencdev |
Yeah, you can. There are a thousand ways to skin this cat. There isn’t a right or wrong way, except ways that just don’t work. But with the plugins, I’m not sure if you can attach behaviors to models in plugins. I could be wrong though, i’ve never done it. |
# |
Feb 8th 2018, 16:27 |
amit |
Can we do it in a behavior |
# |
Feb 8th 2018, 16:26 |
amit |
One more point is I have models in a plugin too |
# |
Feb 8th 2018, 16:25 |
amit |
Exactly |
# |
Feb 8th 2018, 16:25 |
spencdev |
Yeap. What you don’t want is database entries without the file existing in the object storage. That just creates confusion for everyone. |
# |
Feb 8th 2018, 16:24 |
neon1024 |
Especially with a remote data store |
# |
Feb 8th 2018, 16:23 |
neon1024 |
Also consider write failure |
# |
Feb 8th 2018, 16:23 |
spencdev |
Depends on how YOU want to do it. I do mine beforeSave, I want to make sure the upload was successful before submitting the db entry because I do validation on the filename before marshaling. That a little outside of what CakePHP does/used for. You could do it the other way, save into the database and afterSave upload the image. If the image doesn’t upload, roll back. I think that’s how that would work. |
# |
Feb 8th 2018, 16:21 |
neon1024 |
https://book.cakephp.org/3.0/en/orm/saving-data.html#converting-request-data-into-entities |
# |
Feb 8th 2018, 16:21 |
neon1024 |
From the book, https://book.cakephp.org/3.0/en/_images/validation-cycle.png |