Log message #4197630

# At Username Text
# Aug 13th 2019, 02:51 challgren might want a central cache location for your session since it auto scales
# Aug 13th 2019, 02:51 claudio 'Session' => [ 'defaults' => 'cake', 'timeout' => 480 ...
# Aug 13th 2019, 02:49 challgren How are you storing your cookies?
# Aug 13th 2019, 02:49 claudio Hi everyone. My current Cake website is hosted in AWS and it allows for auto scaling, works perfectly but recently having migrated to a newer version of cake, we started using the Csrf component ( Not the middleware ) but when the when the server auto scales I sometimes get a token mismatch exception, any way to fix this issue? Thanks
# Aug 13th 2019, 02:34 latenal @challgren, thanks. It worked. But while I was doing it, I realized that it works as well if I interchange the func and value as `$entityId => 'json_extract(`data`, “$.user_id”)’`
# Aug 13th 2019, 02:13 challgren Youd have to use a query function https://book.cakephp.org/3.0/en/orm/query-builder.html#custom-functions
# Aug 13th 2019, 01:55 slackebot1 ignored). How do I fix it?
# Aug 13th 2019, 01:55 latenal I have a simple query ``` $query = $this->Logs ->find() ->select(['Logs.id', 'Logs.action', 'Logs.ip', 'Logs.created']); $conditions = [ 'OR' => [ 'user_id' => $entityId, "JSON_EXTRACT(`data`, '$.user_id') =" => $entityId ] ]; $query = $query->where($conditions); ``` When I run it I get only 1 value (`JSON_EXTRACT` seems to be
# Aug 12th 2019, 22:12 slackebot1 and it's in the middle of the night, so that's all I have for now, you get the idea :slightly_smiling_face:
# Aug 12th 2019, 22:12 ndm @scuadra And here's a quick and dirty example for `belongsToMany` for DBMS' that do support window functions: https://gist.github.com/ndm2/b417e3fa683a972e295dc0e24ef515e3. That might not be the best way to do it, like, there's a redundant `IN` condition, I'm not sure how well this will work with additional conditions on the association, using `FROM` instead of a `JOIN` for the ranked data might be better, etc, but after all it's just an example,
# Aug 12th 2019, 21:58 ricksaccous @latenal thanks, the rule idea helped, my code is less convoluted now
# Aug 12th 2019, 21:03 slackebot1 $retailTable->find() ->where(['product_id' => $entity->id]) ->count(); return $retail + $wholesale > 0 || !$entity->visible; }, 'visible', [ 'message' => 'Fill in the inventory first', 'errorField' => 'visible' ]); ```
# Aug 12th 2019, 21:03 latenal Here it is: ``` <?php // Check minimum qty $rules->add(function ($entity, $options) { $wholesaleTable = TableRegistry::getTableLocator()->get('ProductWholesalePrices'); $wholesale = $wholesaleTable->find() ->where(['product_id' => $entity->id]) ->count(); $retailTable = TableRegistry::getTableLocator()->get('ProductRetailPrices'); $retail =
# Aug 12th 2019, 21:01 latenal I am looking for a code sample..
# Aug 12th 2019, 21:00 ricksaccous rather than whatever i'm doing
# Aug 12th 2019, 21:00 ricksaccous hmm that might be a decent idea actually
# Aug 12th 2019, 20:59 latenal I’ve done it in `buildRules`
# Aug 12th 2019, 20:31 ricksaccous hmmmm
# Aug 12th 2019, 20:31 ricksaccous i mean evaluate conditionally
# Aug 12th 2019, 20:30 ricksaccous the entity doesn't seem to be passed into "context"
# Aug 12th 2019, 20:30 ricksaccous rather than the request data
# Aug 12th 2019, 20:30 ricksaccous also what's the best way to deal with a situation where the data i want to evaluate is in the entity
# Aug 12th 2019, 20:18 ricksaccous is this evil and if so what's a good way to avoid this, lol
# Aug 12th 2019, 20:17 slackebot1 <ricksaccous>
# Aug 12th 2019, 20:01 latenal ok, thanks
# Aug 12th 2019, 20:00 ricksaccous however you see fit i suppose
# Aug 12th 2019, 19:57 latenal preg_replace?
# Aug 12th 2019, 19:56 latenal how do I do that?
# Aug 12th 2019, 19:56 ricksaccous that's prob one of the only things you'll have to escape i believe, like conditions and places where the param can have special keywords that have unintended consequences
# Aug 12th 2019, 19:55 latenal I am afraid, the sql will look like `title LIKE '%some%'`
# Aug 12th 2019, 19:54 latenal and even if `$title = ‘some%’;
# Aug 12th 2019, 19:53 latenal so will it work if I use this: `$query->where(['title LIKE' => '%' . $title]);`?
# Aug 12th 2019, 19:52 ricksaccous what's the best way to achieve this validation wise
# Aug 12th 2019, 19:52 ricksaccous suppose i want to pop an error in a related model based on the parent model's context
# Aug 12th 2019, 19:50 diego182 quote identifiers
# Aug 12th 2019, 19:50 ricksaccous even then, the ORM offers other options
# Aug 12th 2019, 19:49 ricksaccous the orm uses binded params so you don't have to do that, unless you are using the ORM in a manner where your fields are on the left of the [ $fieldHere => 1] where clause
# Aug 12th 2019, 19:49 challgren The ORM does that for you
# Aug 12th 2019, 19:49 diego182 theres no need for that
# Aug 12th 2019, 19:48 latenal Hey guys, how do you escape var before using it in ORM? I am referring to things like “mysqli_real_escape”?
# Aug 12th 2019, 19:34 Guest7181 hello, I am trying to use the ldap identifier to authenticate the user with the orm resolver to resolve the identity based on the username used for ldap. I am having trouble getting this to work with what is in the book about Indentity Resolvers. Any advice would be appreciated