Log message #4223764

# At Username Text
# Jan 24th 2020, 10:07 challgren That gist may need some cleanup but it should work for yah. I honestly havent used it in a year or so
# Jan 24th 2020, 10:06 alexdd55976 Is there any way to catch the error log writing process and trigger something with that information
# Jan 24th 2020, 10:05 challgren https://gist.github.com/challgren/fbe500197d09f584a0fbc2aac710d3b6
# Jan 24th 2020, 10:04 neon1024 Duplicatable has a 4 branch, TIL
# Jan 24th 2020, 10:04 neon1024 @challgren Countercache, I’m running 3.8
# Jan 24th 2020, 10:04 alexdd55976 Morning
# Jan 24th 2020, 10:04 challgren no for counter cache
# Jan 24th 2020, 10:04 neon1024 I’m not aware that the duplicatable behaviour supports 4
# Jan 24th 2020, 10:03 neon1024 Which I presume is because its’ looking for a property called `script_composed_of`, but I’ve aliased it to `'propertyName' => 'parts',`
# Jan 24th 2020, 10:03 challgren neon 3 or 4?
# Jan 24th 2020, 10:03 neon1024 https://github.com/riesenia/cakephp-duplicatable/blob/master/src/Model/Behavior/DuplicatableBehavior.php#L269
# Jan 24th 2020, 10:03 neon1024 ```Warning (2): Invalid argument supplied for foreach() [ROOT/vendor/riesenia/cakephp-duplicatable/src/Model/Behavior/DuplicatableBehavior.php, line 269]```
# Jan 24th 2020, 10:02 neon1024 Anyone know if the Duplicatable behaviour works with custom property names?
# Jan 24th 2020, 09:51 neon1024 Or am I imagining that? I was sure there was a method to populate initial values, rather than them all being 0 until an update
# Jan 24th 2020, 09:50 neon1024 Wasn’t there a shell command for calculating counter cache?
# Jan 24th 2020, 08:28 challgren Evening all
# Jan 24th 2020, 08:20 gianmarxgagliardi morning all
# Jan 24th 2020, 06:24 matiur756 good morning everybody
# Jan 24th 2020, 06:24 javier.villanueva morning all
# Jan 23rd 2020, 22:09 ndm you're welcome
# Jan 23rd 2020, 21:57 k4t Thank you guys for your time! Really appreciate
# Jan 23rd 2020, 21:57 k4t I cant wait :P
# Jan 23rd 2020, 21:43 ndm Well, we'll see again when you need to paginate such a query, or when you want to apply certain behaviors on the associated table :grimacing:
# Jan 23rd 2020, 21:37 k4t I understand that this is maybe wrong ->matching usage but finally it is generating one and correct query
# Jan 23rd 2020, 21:36 ndm What has that query ever done to you? ;)
# Jan 23rd 2020, 21:36 k4t I still dont super like it but it is the only way to avoid additional queries
# Jan 23rd 2020, 21:35 k4t I think it is just easier to use ->matching which will generate one correct SQL and use results formatter to reformat returned array with data
# Jan 23rd 2020, 21:31 slackebot ->innerJoinWith('Posts') ->where([...]) })```
# Jan 23rd 2020, 21:31 ndm For one you could try the `subquery` strategy, but I'm not sure that it will actually select all the required fields, or that you can affect that. ```->contain([ 'Comments' => [ 'strategy' => 'subquery', 'queryBuilder' => function($q) { return $q->where([...]) } ] )``` Another way might be to join in the `Posts` association. ```->contain('Comments', function($q) { return $q
# Jan 23rd 2020, 21:25 k4t not in comments tabl
# Jan 23rd 2020, 21:25 k4t yes it is a field in posts table
# Jan 23rd 2020, 21:24 ndm What is `Posts.the_oldest_available_post`? Is that an actual field in the schema?
# Jan 23rd 2020, 21:16 slackebot 'Comments.release_date >= Posts.the_oldest_available_post' ]); } ) ->group('Posts.id')```
# Jan 23rd 2020, 21:16 k4t ``` return $query ->innerJoinWith( 'Comments', function ($q) { return $q ->where([ 'Comments.release_date >= Posts.the_oldest_available_post' ]); } ) ->contain( 'Comments', function ($q) { return $q ->where([
# Jan 23rd 2020, 21:15 k4t that one above is the 2nd select
# Jan 23rd 2020, 21:14 k4t it is because ->contain for hasMany generates 2 separated selects
# Jan 23rd 2020, 21:14 k4t ```SELECT Comment.id AS `Comment__id`, Comment.post_id AS `Comment__post_id`, Comment.created_at AS `Comment__created_at`, FROM Comments Comment WHERE (Comment.post_id in (:c0) AND Comment.created_at >= Posts.the_oldest_available_post AND Comment.published = :c1```
# Jan 23rd 2020, 21:04 ndm Let's have a look at it, maybe there's a fix for that.
# Jan 23rd 2020, 21:03 k4t I have that case right now in front of my eyes :P
# Jan 23rd 2020, 21:02 ndm Maybe, but I'd have to see it to believe it ;)
# Jan 23rd 2020, 21:00 k4t sometimes it is not possible to make exactly the same conditions for matching and contain as it will generate broken SQL