< 032022-11-04⋎05 >

Topic for #farmOS is: farmOS (farmos.org) is a free and open source, web-based farm management system. User guide: farmos.org/guide/ - Forum: farmOS.discourse.groupSet by mstenta on 2021-06-15 at 12:52
09:00*donblair[m] has quit (Quit: You have been kicked for being idle)
14:42jgaehring[m]<paul121[m]> "interesting. I wonder if we..." <- oh, I just realized we actually never setup a GHA workflow for the blog repo, working on one now based on an old version of the farmOS workflow that also included a step for PR's
14:47jgaehring[m]gonna update github.com/farmOS/farmOS-community-blog/ with some of these comments and push that workflow up as a PR in a moment
14:53paul121[m]See github.com/farmOS/farmOS-community-blog/ !!
14:53paul121[m]:-)
14:56symbioquine[m]<paul121[m]> "interesting. I wonder if we..." <- I was kinda imagining this would be how it could work too
16:32paul121[m]ohhh Farmer Ed someone just asked this in Drupal slack:
16:32paul121[m]> When a new entity is created via a JSON:API POST, are any entity insert hooks/listeners called?
16:33paul121[m][Overa](drupal.slack.com/archives/C5A70F7D1/p166)
16:33mstenta[m]We didn't directly confirm that... but we think they are, right?
16:33paul121[m]s/[Overa](//
16:33paul121[m]Yeah we think they are. And the slack thread seems to indicate that they are as well
16:34mstenta[m]It seemed to me like the Drupal core entity storage base class was invoking those hooks on $entity->save() so I feel pretty confident
16:37FarmerEd[m]I haven't had time to look at it further yet, but I didn't get it to work for me.
16:39FarmerEd[m]Although I thought it had previously (as in months ago)
16:41symbioquine[m]<paul121[m]> "[Overa](drupal.slack.com..." <- I'm not much of a Slack user... how would I expect to be able to access that link?
16:42paul121[m]sorry :-( I don't know of alternatives for that
16:43symbioquine[m]I don't mean alternatives to Slack per se... just I'm not quite sure I follow the whole workspaces mechanism... would I need some sort of invite to access the link?
16:44mstenta[m](I'm still grumbling that Drupal moved off of IRC how ever many years ago now...)
16:44mstenta[m](I think I did see a thread where some were proposing moving to Matrix.org... probably not going to happen though... sunk cost and all)
16:45symbioquine[m]Matrix seems like a pretty decent alternative to IRC, but as far as I can tell Slack seems like a needlessly walled garden thingy...
16:45mstenta[m]I think you need to create a drupal.slack.com account symbioquine
16:45symbioquine[m]ah
16:45paul121[m]ah yeah the slack workspaces still confuse me. but yes ☝️
16:46paul121[m]and this thread is in the `#contenta` channel
16:47symbioquine[m]Seems like drupal.org is having 500 errors :(
16:48symbioquine[m]But I guess I'd need to follow this link once it's back online: www.drupal.org/join-slack
16:48paul121[m]another annoyance of mine... only have a vague understanding that "contenta" is a prominent drupal organization... yet this is where all the Drupal API discussions happen 🙄
16:48symbioquine[m]webcache.googleusercontent.com/search?q=
16:52mstenta[m]drupal.slack.com should work directly symbioquine ?
16:52mstenta[m]> Seems like drupal.org is having 500 errors :(
16:52mstenta[m]I'm sure they are talking about it in the #infrastruture slack channel haha
16:52paul121[m]maybe if we all just start talking about Drupal json:api, api, etc etc in a new matrix channel we can start the migration :-)
16:56FarmerEd[m]I'm getting 500 errors trying install a module from drupal using composer too
16:56mstenta[m]yea looks like some issues...
16:56FarmerEd[m]also cant sign up for the slack channel at the moment
16:57mstenta[m]twitter.com/drupal_infra/status/15885609
16:57mstenta[m]@drupal_infra is another place to check for those kinda things
16:57mstenta[m]ouch seems to be pretty broad
16:57symbioquine[m]Of course the links from the tweet also 500 🫠
16:58paul121[m]lets just take the day off folks
16:58mstenta[m]giphy.com/gifs/community-fire-shocked-nL
16:58paul121[m]it snowed here - first snow day :-)
16:58mstenta[m]nice!
18:05FarmerEd[m]Drupal.org seems to be back now
18:07FarmerEd[m]Managed to checkout slack and use composer
18:25FarmerEd[m]anyone seeing errors like: Uncaught PHP Exception Twig\\Error\\LoaderError: "Template "@claro/../images/src/hamburger-menu.svg" is not defined in "core/themes/claro/templates/navigation/menu-local-task.html.twig
18:26mstenta[m]oh yea... that was an upstream issue that got fixed in Drupal 9.4.6 (if i remember correctly)
18:26mstenta[m]farmOS 2.0.0-beta7 pins to that now
18:26mstenta[m]if you rebuilt via composer, it inadvertently updated the twig library, which broke Gin/Claro themes
18:26FarmerEd[m]Ah maybe need to update the dev image
18:27mstenta[m]the other option (if you're not ready to update) is to manually pin the twig version in your `composer.json`
18:27FarmerEd[m]yea, pretty much, fixed it by downgrading twig
18:27mstenta[m]ah.. are you using the `docker-compose.development.yml` template?
18:27FarmerEd[m]yes I think so
18:28mstenta[m]if so, updating the `farmos/farmos:2.x-dev` docker image won't do it... because you have the whole built codebase mounted as a volume
18:28mstenta[m](if you were only mounting `sites` then you'd be using the codebase in the image)
18:28FarmerEd[m]yes that would make sense
18:29FarmerEd[m]its only a dev instance with very little in it so can be destroyed and started a fresh at this stage
18:30FarmerEd[m]Was more just making sure there was awareness of the issue.
18:31mstenta[m]thanks! yea i ran into that too
18:32mstenta[m](and MANY users of Gin and Claro themes)
18:32mstenta[m]www.drupal.org/project/drupal/issues/331
18:33FarmerEd[m]no bother so,
18:33FarmerEd[m]I had come across it last week too but hadn't made the composer connection and just restored the image as figured I'd just done something stupid
18:41FarmerEd[m]Ok.................
18:41FarmerEd[m]I may have discovered something
18:41FarmerEd[m]hook_ENTITY_TYPE_update() is not working for me for entities created through the API but does from the UI
18:41FarmerEd[m]hook_ENTITY_TYPE_insert() does work for entities created through the API
18:41mstenta[m]OH! yesssss
18:41mstenta[m]_update() only works with EDITS
18:41mstenta[m]_insert() only works with CREATES
18:41mstenta[m]oh wait...
18:42mstenta[m]re-reading what you said more closely...
18:42FarmerEd[m]but entities created in the UI still fire as an edit?
18:42mstenta[m]gotcha
18:42mstenta[m]maybe what's happening is they are being saved twice when you save through UI
18:42mstenta[m]for some reason
18:42FarmerEd[m]because they are created from a form
18:42FarmerEd[m]??
18:43mstenta[m]yea not sure!
18:43mstenta[m]it must be saving it twice
18:43mstenta[m]that would be my guess
18:43mstenta[m]so the first one is an insert, and the second is an update (which you were seeing)
18:43mstenta[m](maybe?)
18:44FarmerEd[m]would that not cause a version increment of the log?
18:44mstenta[m]another revision you mean? not necessarily... i think that needs to be explicitly done... and we do that automatically for API and UI saves IIRC
18:45mstenta[m](but not for every ->save() that happens in code)
18:45FarmerEd[m]Yes, brain couldn't come up with revision for some reason :D
18:48FarmerEd[m]OK, so at least I know what's wrong with my module
18:48FarmerEd[m]Might need to rethink a few bits, I thought it was nice that update, covered creation also, but it's a little annoying if the API and UI don't behave the same.
18:49mstenta[m]yea you should always use _insert() and _update() separately
18:49mstenta[m]i would be curious to figure out why BOTH are running on a UI creation though
18:50mstenta[m]maybe that's a bug... or if not, then maybe you will want to filter out some of the _update() executions
18:51mstenta[m]a traceback in _update() would probably tell us what's happening
18:51FarmerEd[m]Yea, I can see the sense in that and it wouldn't be an issue if they both behaved the same
18:51FarmerEd[m]API and UI that is
18:52mstenta[m]yea i'm curious what else is firing
18:52mstenta[m]and why it differs via API and UI
18:56FarmerEd[m]Guess I need to go sort out a proper IDE for myself
18:58mstenta[m]that would be best! but you could also get away with just throwing some logging lines into your hooks
18:58mstenta[m]\Drupal::logger('mymodule')->error('my message');
18:58mstenta[m]that will put stuff in /admin/reports/dblog
18:59mstenta[m]although it only works with strings... but one trick is to json encode a var and then log that
18:59mstenta[m]\Drupal::logger('mymodule')->error(json_encode($var));
18:59mstenta[m]this might be fun:
19:00mstenta[m]\Drupal::logger('mymodule')->error(json_encode(debug_backtrace()));
19:00mstenta[m]or it might be crazy! 😄
19:00mstenta[m]gtg pick up kid from school 👋
19:00FarmerEd[m]No problem, thanks again
19:07paul121[m]<mstenta[m]> "i would be curious to figure out..." <- Interesting! Curious if this is an asset or log. For logs we do have some logic that will update the log after creation if needed eg: copy the location geometry onto the log
19:08FarmerEd[m]It is a log and that might make perfect sense, as I sent the bare minimum in the API to create a log with a note.
19:13mstenta[m]That should be happening via API too though 🤔
19:13mstenta[m]But maybe you referenced a location in UI but not API?
19:15FarmerEd[m]No was creating logs with the bare minimum in both cases.
19:15mstenta[m]Hmm then that's probably not where the extra save is happening
19:16mstenta[m]Might be worth confirming that this hypothesis of two saves is correct first
19:16mstenta[m]By logging a simple string in both insert and update hooks
20:00FarmerEd[m]I presume you mean using both hooks at the same time?
20:00mstenta[m]yea
20:00mstenta[m]with just a simple log message going to /admin/reports/dblog to see which fire
20:14FarmerEd[m]More confused than ever now as they seem to be working the way they should??
20:17mstenta[m]are you seeing both insert and update fire when you create a log through the UI?
20:19FarmerEd[m]I take it back,,,, both fire from the UI not sure I cleared the cache :D
20:20*uploaded an image: (14KiB) < libera.ems.host/_matrix/media/v3/downloa >
20:21mstenta[m]ok try adding this one to the update:
20:21mstenta[m]> \Drupal::logger('mymodule')->error(json_encode(debug_backtrace()));
20:25FarmerEd[m]comes back blank
20:26mstenta[m]oh hmm
20:26mstenta[m]maybe that can't be json encoded
20:26mstenta[m]what about debug_backtrace()[0]
20:34FarmerEd[m]just says array
20:34FarmerEd[m]but I've noticed something and paul121 is probably right
20:35FarmerEd[m]using an automatic log name fires both but a manual log name only fires one
20:36mstenta[m]Ahhh
20:38mstenta[m]git.drupalcode.org/project/log/-/blob/2.
20:39mstenta[m]I wonder if we could move that to a presave
20:39mstenta[m]Oh wait nope
20:39mstenta[m]// We must run the parent method before we set the name, so that new logs // have an ID that can be used in token replacements. // Also, we must run the parent method after the logic above, because the // parent method unsets $entity->original.
20:40mstenta[m]In order to generate a name it needs a log ID
20:40FarmerEd[m]of course
20:40mstenta[m]Well at least you discovered the cause!
20:41mstenta[m]And should be able to work around it?
20:44FarmerEd[m]presumably, might need a bit more fiddling and testing but at least I know what I'm dealing with
21:00FarmerEd[m]and just to confirm, omitting the log name from API triggers the update hook
21:02mstenta[m]ah ha! great!
21:02mstenta[m]thanks for checking all that
21:07FarmerEd[m]Great to get it figured out, was digging myself into a hole for a while there.
21:07FarmerEd[m]Now to scrap this module and make some plugins for the core notifications module.

< 032022-11-04⋏05 >