| 09:00 | * | donblair[m] has quit (Quit: You have been kicked for being idle) |
| 14:42 | jgaehring[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:47 | jgaehring[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:53 | paul121[m] | See github.com/farmOS/farmOS-community-blog/ !! |
| 14:53 | paul121[m] | :-) |
| 14:56 | symbioquine[m] | <paul121[m]> "interesting. I wonder if we..." <- I was kinda imagining this would be how it could work too |
| 16:32 | paul121[m] | ohhh Farmer Ed someone just asked this in Drupal slack: |
| 16:32 | paul121[m] | > When a new entity is created via a JSON:API POST, are any entity insert hooks/listeners called? |
| 16:33 | paul121[m] | [Overa](drupal.slack.com/archives/C5A70F7D1/p166) |
| 16:33 | mstenta[m] | We didn't directly confirm that... but we think they are, right? |
| 16:33 | paul121[m] | s/[Overa](// |
| 16:33 | paul121[m] | Yeah we think they are. And the slack thread seems to indicate that they are as well |
| 16:34 | mstenta[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:37 | FarmerEd[m] | I haven't had time to look at it further yet, but I didn't get it to work for me. |
| 16:39 | FarmerEd[m] | Although I thought it had previously (as in months ago) |
| 16:41 | symbioquine[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:42 | paul121[m] | sorry :-( I don't know of alternatives for that |
| 16:43 | symbioquine[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:44 | mstenta[m] | (I'm still grumbling that Drupal moved off of IRC how ever many years ago now...) |
| 16:44 | mstenta[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:45 | symbioquine[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:45 | mstenta[m] | I think you need to create a drupal.slack.com account symbioquine |
| 16:45 | symbioquine[m] | ah |
| 16:45 | paul121[m] | ah yeah the slack workspaces still confuse me. but yes ☝️ |
| 16:46 | paul121[m] | and this thread is in the `#contenta` channel |
| 16:47 | symbioquine[m] | Seems like drupal.org is having 500 errors :( |
| 16:48 | symbioquine[m] | But I guess I'd need to follow this link once it's back online: www.drupal.org/join-slack |
| 16:48 | paul121[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:48 | symbioquine[m] | webcache.googleusercontent.com/search?q= |
| 16:52 | mstenta[m] | drupal.slack.com should work directly symbioquine ? |
| 16:52 | mstenta[m] | > Seems like drupal.org is having 500 errors :( |
| 16:52 | mstenta[m] | I'm sure they are talking about it in the #infrastruture slack channel haha |
| 16:52 | paul121[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:56 | FarmerEd[m] | I'm getting 500 errors trying install a module from drupal using composer too |
| 16:56 | mstenta[m] | yea looks like some issues... |
| 16:56 | FarmerEd[m] | also cant sign up for the slack channel at the moment |
| 16:57 | mstenta[m] | twitter.com/drupal_infra/status/15885609 |
| 16:57 | mstenta[m] | @drupal_infra is another place to check for those kinda things |
| 16:57 | mstenta[m] | ouch seems to be pretty broad |
| 16:57 | symbioquine[m] | Of course the links from the tweet also 500 🫠 |
| 16:58 | paul121[m] | lets just take the day off folks |
| 16:58 | mstenta[m] | giphy.com/gifs/community-fire-shocked-nL |
| 16:58 | paul121[m] | it snowed here - first snow day :-) |
| 16:58 | mstenta[m] | nice! |
| 18:05 | FarmerEd[m] | Drupal.org seems to be back now |
| 18:07 | FarmerEd[m] | Managed to checkout slack and use composer |
| 18:25 | FarmerEd[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:26 | mstenta[m] | oh yea... that was an upstream issue that got fixed in Drupal 9.4.6 (if i remember correctly) |
| 18:26 | mstenta[m] | farmOS 2.0.0-beta7 pins to that now |
| 18:26 | mstenta[m] | if you rebuilt via composer, it inadvertently updated the twig library, which broke Gin/Claro themes |
| 18:26 | FarmerEd[m] | Ah maybe need to update the dev image |
| 18:27 | mstenta[m] | the other option (if you're not ready to update) is to manually pin the twig version in your `composer.json` |
| 18:27 | FarmerEd[m] | yea, pretty much, fixed it by downgrading twig |
| 18:27 | mstenta[m] | ah.. are you using the `docker-compose.development.yml` template? |
| 18:27 | FarmerEd[m] | yes I think so |
| 18:28 | mstenta[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:28 | mstenta[m] | (if you were only mounting `sites` then you'd be using the codebase in the image) |
| 18:28 | FarmerEd[m] | yes that would make sense |
| 18:29 | FarmerEd[m] | its only a dev instance with very little in it so can be destroyed and started a fresh at this stage |
| 18:30 | FarmerEd[m] | Was more just making sure there was awareness of the issue. |
| 18:31 | mstenta[m] | thanks! yea i ran into that too |
| 18:32 | mstenta[m] | (and MANY users of Gin and Claro themes) |
| 18:32 | mstenta[m] | www.drupal.org/project/drupal/issues/331 |
| 18:33 | FarmerEd[m] | no bother so, |
| 18:33 | FarmerEd[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:41 | FarmerEd[m] | Ok................. |
| 18:41 | FarmerEd[m] | I may have discovered something |
| 18:41 | FarmerEd[m] | hook_ENTITY_TYPE_update() is not working for me for entities created through the API but does from the UI |
| 18:41 | FarmerEd[m] | hook_ENTITY_TYPE_insert() does work for entities created through the API |
| 18:41 | mstenta[m] | OH! yesssss |
| 18:41 | mstenta[m] | _update() only works with EDITS |
| 18:41 | mstenta[m] | _insert() only works with CREATES |
| 18:41 | mstenta[m] | oh wait... |
| 18:42 | mstenta[m] | re-reading what you said more closely... |
| 18:42 | FarmerEd[m] | but entities created in the UI still fire as an edit? |
| 18:42 | mstenta[m] | gotcha |
| 18:42 | mstenta[m] | maybe what's happening is they are being saved twice when you save through UI |
| 18:42 | mstenta[m] | for some reason |
| 18:42 | FarmerEd[m] | because they are created from a form |
| 18:42 | FarmerEd[m] | ?? |
| 18:43 | mstenta[m] | yea not sure! |
| 18:43 | mstenta[m] | it must be saving it twice |
| 18:43 | mstenta[m] | that would be my guess |
| 18:43 | mstenta[m] | so the first one is an insert, and the second is an update (which you were seeing) |
| 18:43 | mstenta[m] | (maybe?) |
| 18:44 | FarmerEd[m] | would that not cause a version increment of the log? |
| 18:44 | mstenta[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:45 | mstenta[m] | (but not for every ->save() that happens in code) |
| 18:45 | FarmerEd[m] | Yes, brain couldn't come up with revision for some reason :D |
| 18:48 | FarmerEd[m] | OK, so at least I know what's wrong with my module |
| 18:48 | FarmerEd[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:49 | mstenta[m] | yea you should always use _insert() and _update() separately |
| 18:49 | mstenta[m] | i would be curious to figure out why BOTH are running on a UI creation though |
| 18:50 | mstenta[m] | maybe that's a bug... or if not, then maybe you will want to filter out some of the _update() executions |
| 18:51 | mstenta[m] | a traceback in _update() would probably tell us what's happening |
| 18:51 | FarmerEd[m] | Yea, I can see the sense in that and it wouldn't be an issue if they both behaved the same |
| 18:51 | FarmerEd[m] | API and UI that is |
| 18:52 | mstenta[m] | yea i'm curious what else is firing |
| 18:52 | mstenta[m] | and why it differs via API and UI |
| 18:56 | FarmerEd[m] | Guess I need to go sort out a proper IDE for myself |
| 18:58 | mstenta[m] | that would be best! but you could also get away with just throwing some logging lines into your hooks |
| 18:58 | mstenta[m] | \Drupal::logger('mymodule')->error('my message'); |
| 18:58 | mstenta[m] | that will put stuff in /admin/reports/dblog |
| 18:59 | mstenta[m] | although it only works with strings... but one trick is to json encode a var and then log that |
| 18:59 | mstenta[m] | \Drupal::logger('mymodule')->error(json_encode($var)); |
| 18:59 | mstenta[m] | this might be fun: |
| 19:00 | mstenta[m] | \Drupal::logger('mymodule')->error(json_encode(debug_backtrace())); |
| 19:00 | mstenta[m] | or it might be crazy! 😄 |
| 19:00 | mstenta[m] | gtg pick up kid from school 👋 |
| 19:00 | FarmerEd[m] | No problem, thanks again |
| 19:07 | paul121[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:08 | FarmerEd[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:13 | mstenta[m] | That should be happening via API too though 🤔 |
| 19:13 | mstenta[m] | But maybe you referenced a location in UI but not API? |
| 19:15 | FarmerEd[m] | No was creating logs with the bare minimum in both cases. |
| 19:15 | mstenta[m] | Hmm then that's probably not where the extra save is happening |
| 19:16 | mstenta[m] | Might be worth confirming that this hypothesis of two saves is correct first |
| 19:16 | mstenta[m] | By logging a simple string in both insert and update hooks |
| 20:00 | FarmerEd[m] | I presume you mean using both hooks at the same time? |
| 20:00 | mstenta[m] | yea |
| 20:00 | mstenta[m] | with just a simple log message going to /admin/reports/dblog to see which fire |
| 20:14 | FarmerEd[m] | More confused than ever now as they seem to be working the way they should?? |
| 20:17 | mstenta[m] | are you seeing both insert and update fire when you create a log through the UI? |
| 20:19 | FarmerEd[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:21 | mstenta[m] | ok try adding this one to the update: |
| 20:21 | mstenta[m] | > \Drupal::logger('mymodule')->error(json_encode(debug_backtrace())); |
| 20:25 | FarmerEd[m] | comes back blank |
| 20:26 | mstenta[m] | oh hmm |
| 20:26 | mstenta[m] | maybe that can't be json encoded |
| 20:26 | mstenta[m] | what about debug_backtrace()[0] |
| 20:34 | FarmerEd[m] | just says array |
| 20:34 | FarmerEd[m] | but I've noticed something and paul121 is probably right |
| 20:35 | FarmerEd[m] | using an automatic log name fires both but a manual log name only fires one |
| 20:36 | mstenta[m] | Ahhh |
| 20:38 | mstenta[m] | git.drupalcode.org/project/log/-/blob/2. |
| 20:39 | mstenta[m] | I wonder if we could move that to a presave |
| 20:39 | mstenta[m] | Oh wait nope |
| 20:39 | mstenta[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:40 | mstenta[m] | In order to generate a name it needs a log ID |
| 20:40 | FarmerEd[m] | of course |
| 20:40 | mstenta[m] | Well at least you discovered the cause! |
| 20:41 | mstenta[m] | And should be able to work around it? |
| 20:44 | FarmerEd[m] | presumably, might need a bit more fiddling and testing but at least I know what I'm dealing with |
| 21:00 | FarmerEd[m] | and just to confirm, omitting the log name from API triggers the update hook |
| 21:02 | mstenta[m] | ah ha! great! |
| 21:02 | mstenta[m] | thanks for checking all that |
| 21:07 | FarmerEd[m] | Great to get it figured out, was digging myself into a hole for a while there. |
| 21:07 | FarmerEd[m] | Now to scrap this module and make some plugins for the core notifications module. |