Log message #4192508

# At Username Text
# Jul 9th 2019, 14:48 brian493 I'm doing this: ``` $dataSource = $this->getDataSource(); $dataSource->begin(); .. call create() and then save() on my model here a bunch of times in a loop .. $dataSource->commit(); ```
# Jul 9th 2019, 14:47 brian493 new question. while I was testing that I refreshed my table and I could see it filling the table with rows in realtime. shouldn't I only see new rows after the transaction completes?
# Jul 9th 2019, 14:46 brian493 ok so I can do a DELETE FROM and that will work
# Jul 9th 2019, 14:44 brian493 hmm I think you are right
# Jul 9th 2019, 14:44 dereuromark never done it inside transactions tbh
# Jul 9th 2019, 14:43 dereuromark is truncation maybe not a recoverable (transaction safe) op?
# Jul 9th 2019, 14:43 brian493 question, in cake2 I'm calling $this->Modal->query('TRUNCATE TABLE MyTable'); inside a transaction which isn't working (It's truncating the table as if it was run outside of the transaction). What is the correct way to truncate a table so that it occurs within the transaction?
# Jul 9th 2019, 14:41 rochasmarcelo @newyorknick how are you reading the data from session?
# Jul 9th 2019, 14:35 half2me everywhere where I have problems, its always inside of a beforeSave()
# Jul 9th 2019, 14:29 half2me I know it has something to do with it being run inside of a transaction
# Jul 9th 2019, 14:25 neon1024 Ah, I bet it’s my listener filtering the associated query, although I did set a check on `$primary`
# Jul 9th 2019, 14:23 neon1024 I set a `user_id` to my entity in the controller, using the currently logged in users id, however my entity has errors for `user_id (array) _existsIn This value does not exist` and I have no idea why when the value is there
# Jul 9th 2019, 14:19 admad ;)
# Jul 9th 2019, 14:19 jeremy.payne @admad you sent me on the right track. looks like the nginx config (I don't have access to it) is catching all non POST/GET stuff and forcing an error page for them.
# Jul 9th 2019, 14:13 admad np
# Jul 9th 2019, 14:13 jeremy.payne I was hoping it wasn't so I don't have to spend too many hours digging, but it looks like I do. I'll continue investigating. Thanks for your help @neon1024 and @admad
# Jul 9th 2019, 14:12 jeremy.payne Yeah, I'm suspecting it's something in the project's config/setup
# Jul 9th 2019, 14:12 admad looks like your webserver itself is block the requests
# Jul 9th 2019, 14:11 admad it's strange that you get a 405 before controller's beforeFilter is reached
# Jul 9th 2019, 14:10 jeremy.payne I lose the ability to read the list of accepted domains from the db by doing that way sadly
# Jul 9th 2019, 14:07 admad you don't event need to bother with php code. just check request type and return required header in .htacccess / nginx config
# Jul 9th 2019, 14:07 jeremy.payne Cake version is `2.6.8` if that helps
# Jul 9th 2019, 14:07 jeremy.payne but I could allow it on the whole project
# Jul 9th 2019, 14:06 jeremy.payne @admad I have a whole `API` plugin with all the stuff that would require the `options` method to work
# Jul 9th 2019, 14:06 admad @jeremy.payne do you need separate configurations per url?
# Jul 9th 2019, 14:06 jeremy.payne Yeah I tried building a middleware in cake2 first because that's how I would tackle it in cake3 :slightly_smiling_face:
# Jul 9th 2019, 14:05 jeremy.payne Yeah I tried that in the controller's beforeFilter, but it gets a 405 before it even gets that far.
# Jul 9th 2019, 14:05 neon1024 Would make a nice middleware if you were in Cake 3 :slightly_smiling_face:
# Jul 9th 2019, 14:05 neon1024 `$this->request->is('options')` presumably
# Jul 9th 2019, 14:05 neon1024 https://book.cakephp.org/2.0/en/controllers/request-response.html#inspecting-the-request
# Jul 9th 2019, 14:03 neon1024 My Cake 2 is very rusty
# Jul 9th 2019, 14:03 neon1024 `$this->RequestHandler->allowMethod()` perhaps
# Jul 9th 2019, 14:03 neon1024 I think it’s the RequestHandlerComponent in Cake 2?
# Jul 9th 2019, 14:02 neon1024 As you might have the Cake 2 equivalent of `$this->getRequest()->allow(['post', 'put'])` or similar
# Jul 9th 2019, 14:02 neon1024 Then probably just need to update the controller methods if the verbs are not set in the routing
# Jul 9th 2019, 14:02 jeremy.payne A blanket permission would be a terrible idea
# Jul 9th 2019, 14:01 jeremy.payne We plan (or already have the code set up) for allow-origin headers :slightly_smiling_face:
# Jul 9th 2019, 14:01 neon1024 Unless you’re also implementing the Allow-Origin headers
# Jul 9th 2019, 14:00 neon1024 As you have to allow it, I could send 100,000 OPTIONS requests to your enedpoint
# Jul 9th 2019, 14:00 neon1024 As opening your endpoint up to OPTIONS requests will allow for hammering and ddos
# Jul 9th 2019, 13:59 neon1024 We sidestepped the whole issue by proxying the call in a controller using php