Logs for #cakephp

Page 9 of 36,241, showing 100 records out of 3,624,076 total, starting on record 801, ending on 900

# At Username Text
# Aug 13th, 10:35 vossen.steven I don't use it for roles either, was just a crude example to get my point across :)
# Aug 13th, 10:34 challgren enum + bitmask
# Aug 13th, 10:34 challgren I use the enum tools for statuses, roles are a bit too simple IMHO
# Aug 13th, 10:33 vossen.steven That's actually a lot cleaner, never thought about it tbh, my thought process was, I want to do $entity->status_value, oh easy just get the table and pass the entity status :<
# Aug 13th, 10:30 dereuromark Also nicely connects with Bake and autodetect for IDE etc.
# Aug 13th, 10:30 dereuromark https://github.com/dereuromark/cakephp-tools/blob/master/docs/Entity/Enum.md is IMO the easiest and fastest solution :slightly_smiling_face: if you hardcode it anyways.
# Aug 13th, 10:28 challgren Why not like this?
# Aug 13th, 10:26 vossen.steven Not sure if I follow but here's a crude example Table ``` const TYPE_USER = 0; const TYPE_ADMIN = 1; /** @var array */ public $types; public function initialize(array $config) { $this->types = [ self::TYPE_USER => __('User'), self::TYPE_ADMIN => __('Administrator'), ]; } ``` Entity ``` /** * @return string */ protected function _getTypeValue():
# Aug 13th, 10:26 slackebot1 string { return TableRegistry::getTableLocator()->get($this->getSource())->types[$this->type]; } ```
# Aug 13th, 10:21 challgren Why not an association if you already have the tables
# Aug 13th, 10:19 vossen.steven I only use it for const values, for populating selects/radios and instances where I use a variable table name
# Aug 13th, 10:19 vossen.steven @challgren
# Aug 13th, 10:16 dereuromark A rector task for it would make it a super trivial change. For free.
# Aug 13th, 10:16 neothermic and then I can run the fixer to add the return to all of my $this->redirect calls
# Aug 13th, 10:16 neothermic a lot of my controller testing can't happen until another branch is merged in
# Aug 13th, 10:15 challgren Ahh ok
# Aug 13th, 10:15 neothermic 433 test cases
# Aug 13th, 10:15 challgren Weak sauce!
# Aug 13th, 10:14 neothermic @challgren Currently 764
# Aug 13th, 10:12 challgren Looking in my major project I only use it twice, 1 in an entity because ModelAwareTrait screwed up json encoding it. And the other in a table class afterSave event
# Aug 13th, 10:09 neon1024 Here it is if anyone is interested https://github.com/cakephp/cakephp/pull/10933
# Aug 13th, 10:06 challgren https://github.com/dereuromark/cakephp-queue/blame/master/docs/README.md#L320
# Aug 13th, 10:05 challgren I think dereuromark ’s code taught me to use it honestly
# Aug 13th, 10:04 neon1024 ..and to rename some of the api
# Aug 13th, 10:04 neon1024 It got refactored a while ago to try and remove the static interface
# Aug 13th, 10:04 vossen.steven Yea was just thinking getTableLocator probly uses the same obj
# Aug 13th, 10:04 neon1024 @challgren Well that method will be pulling the instance from the registry if one already exists
# Aug 13th, 10:03 challgren Doesn’t make sense to make a new object when sometimes I use getTableLocator() multiple times
# Aug 13th, 10:02 neon1024 @val Good luck! 8)
# Aug 13th, 10:02 challgren IDK honestly, I always coded `TableRegistry::getTableLocator()->get()` well `TableRegistry::get()`
# Aug 13th, 10:02 racmiroslav there is. `TableRegistry::getTableLocator()` is Singleton
# Aug 13th, 10:00 vossen.steven @challgren maybe a dumb question but is there a difference between `TableRegistry::getTableLocator()->get('Table')` and `(new TableLocator())->get('Table')` ?
# Aug 13th, 09:57 val @neon1024 nope, that's not what I asked. In 2.x there is an option to set table alias in data source object. It seems such option is missing in 3.x
# Aug 13th, 09:56 jotpe But skipAuthorization() has no parameter for actions. So how can i allow an action from one Controller?
# Aug 13th, 09:55 jotpe As mentioned over here Authorization can skipped for actions: https://book.cakephp.org/authorization/1.1/en/component.html#automatic-authorization-checks
# Aug 13th, 09:50 challgren Ahhh, how many assertions so far?
# Aug 13th, 09:50 neothermic @challgren also I've had to do other work inbetween writing tests :S
# Aug 13th, 09:49 neon1024 https://github.com/cakephp/cakephp/blob/master/src/Core/ObjectRegistry.php
# Aug 13th, 09:49 neon1024 @val Have a look at the ObjectRegistry class if you’re interested, it’s one of the key patterns for the whole framework, even in Cake 2
# Aug 13th, 09:48 challgren @val maybe someone else knows a better answer, I by no means am a ORM expert
# Aug 13th, 09:48 neon1024 @val That’s exactly what you asked for
# Aug 13th, 09:47 neothermic it gets fun when you have a function with an npath of 442.. :)
# Aug 13th, 09:46 val omg. new table instance for each subquery?! that's insane
# Aug 13th, 09:45 neon1024 It can lead to sub-standard test-cases
# Aug 13th, 09:45 neon1024 Chasing coverage is dangerous
# Aug 13th, 09:44 challgren I had 100% at one time but it dropped to 80% and Im sad about it, but need to focus on getting it back up to 100%
# Aug 13th, 09:43 neon1024 So you can use it later again if needed
# Aug 13th, 09:43 neon1024 ..and you’ll have added an alias to the Registry
# Aug 13th, 09:43 neon1024 Then you can use the return @val
# Aug 13th, 09:43 challgren Yes so you use $Example2->find() as your subquery
# Aug 13th, 09:43 neothermic @challgren unit tests. Working from critical parts forward
# Aug 13th, 09:43 slackebot1 <neon1024>
# Aug 13th, 09:43 challgren Are you just doing integration tests?
# Aug 13th, 09:42 val @challgren the same problem. I need the alias to be applied only to a single subquery.
# Aug 13th, 09:42 neon1024 Probably something like `$t = new TableLocator(); $t->get(‘Cat’, [ ‘className’ => \App\Model\Table\DogsTable::class ])`
# Aug 13th, 09:42 neothermic 0.9% of 500k is still a lot of lines tested
# Aug 13th, 09:42 challgren Damm figured you’d be at least 5%
# Aug 13th, 09:41 neothermic argh, 0.9% covered. gotta keep going to hit that first 1%
# Aug 13th, 09:41 challgren `$Example2 = TableRegistry::getTableLocator()->get('Example')->setAlias('Example2');`
# Aug 13th, 09:41 neon1024 So I guess you’d need to load a new aliased instance
# Aug 13th, 09:40 neon1024 Although as Cake uses the Registry pattern you’ll always be changing the same instance, unless you clone it as @challgren said
# Aug 13th, 09:40 neon1024 `$query->getRepository()->setAlias();`
# Aug 13th, 09:39 challgren Yep not defined.
# Aug 13th, 09:39 val I can't find `setAlias` in Query class
# Aug 13th, 09:39 neon1024 Call it on the query instance instead of the table?
# Aug 13th, 09:37 challgren Try it first and see
# Aug 13th, 09:37 challgren You could clone it
# Aug 13th, 09:36 val not what is needed
# Aug 13th, 09:36 challgren I could see that happening
# Aug 13th, 09:35 val @challgren wouldn't this set 'Example2' alias for all consecutive queries to Example table?
# Aug 13th, 09:35 Martin` When do I need to use Aliasses?
# Aug 13th, 09:34 challgren `$this->Example->setAlias('Example2')->find()`
# Aug 13th, 09:31 val and how a table alias can be set on Query object?
# Aug 13th, 09:12 neon1024 `$newSubQuery = $this->Examples->find()`
# Aug 13th, 09:05 val @admad any example?
# Aug 13th, 08:51 admad Create a separate query instance for the sub query
# Aug 13th, 08:42 val So that the alias would be applied only to that subquery.
# Aug 13th, 08:41 val Hi, what is the safe way to construct a subquery with custom aliases in 3.x?
# Aug 13th, 07:36 neon1024 Hey @jotpe
# Aug 13th, 07:34 jotpe Morning all
# Aug 13th, 06:34 xuanvu442 @admad Thanks bro
# Aug 13th, 05:58 admad @xuanvu442 in cake 3 you can use `bin/cake routes` in CLI to get list of all connected routes, i don't remember if 2.x has the same command
# Aug 13th, 05:10 xuanvu442 Hi everyone! I’ve a small question, hope guys help me. How do I get all the HTTP Request Method available on my project (cakephp 2.x)? Plz see the image!
# Aug 13th, 03:18 challgren Do you have any guide you followed for using AWS?
# Aug 13th, 03:17 claudio Yeah I also checked the code, and looking at AWS it does seem like we don't have cookie stickness enabled, so that might explain the issue. Going to check for the impact in enabling it and then might be the path we take forward. Thanks for the tips :slightly_smiling_face:
# Aug 13th, 03:10 challgren is the webroot different?
# Aug 13th, 03:05 challgren Digging into the code it looks cookie based
# Aug 13th, 02:56 claudio Yeah it's worth the shot, just going to drop a line on the forum to, maybe someone else has some ideas I can try before changing the live server to use database sessions. Thanks for the feedback @challgren
# Aug 13th, 02:54 challgren Id root around in the CsrfComponent and see what its doing there to set it and verify it
# Aug 13th, 02:54 challgren Im not 100% honestly
# Aug 13th, 02:53 claudio component
# Aug 13th, 02:53 challgren Are you using the component or middleware?
# Aug 13th, 02:53 claudio @challgren I actually thought the issue could be there, but testing locally, I did delete the tmp/sessions folder and I didn't get any token mismatch exceptions, I did notice some pages were acting up because the session had gone away, but not the csrf in particular. It's worth the try but I wanted to be sure before trying it out. Anything else worth checking?
# Aug 13th, 02:51 challgren might want a central cache location for your session since it auto scales
# Aug 13th, 02:51 claudio 'Session' => [ 'defaults' => 'cake', 'timeout' => 480 ...
# Aug 13th, 02:49 challgren How are you storing your cookies?
# Aug 13th, 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, 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, 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, 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