< 302026-01-31⋎01 >

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
13:42symbioquine[m]Maybe I'm just being dense, but there's no way to find/cleanup orphaned (unreferenced) quantities in farmOS right?
13:44symbioquine[m]Entity creation isn't atomic so I think such quantities will get randomly created over time in the event of failures of various sorts part-way through the creation of logs.
14:00mstenta[m]You're right
14:00mstenta[m]There's an open issue for this
14:01mstenta[m]And it's partly why we changed /quantities to /log-quantities
14:01mstenta[m]To filter orphaned quantities out of the UI
14:04mstenta[m]The challenge is identifying orphans... if a contrib module adds a quantity field then we don't want to delete those
14:04mstenta[m]But that's probably solvable
14:04symbioquine[m]Makes sense
14:04mstenta[m]Just haven't yet
14:05symbioquine[m]Going down the rabbit hole of seeing how many I have right now...
14:05symbioquine[m]Probably more than the average since I run lots of experimental stuff
14:12mstenta[m]On the bright side, if you know you're only using the core quantity reference on logs, then they are easy to identify and clean up!
14:13mstenta[m]Here is the open issue FYI: github.com/farmOS/farmOS/issues/775
14:13mstenta[m]The title is more specific because that's where it was first discovered
14:15mstenta[m]If you need help with a query/php script to run via Drush I can help
14:17mstenta[m]I thought I had one already on that issue but maybe not
14:17mstenta[m]Oh be mindful of this consideration too: github.com/farmOS/farmOS/issues/775#issu
14:21symbioquine[m]mstenta[m]: > So we would need to make sure we don't delete a quantity that's referenced by a previous log revision.
14:21symbioquine[m]The plot thickens!
14:22symbioquine[m]Next question: will Drupal throw an error if you try and delete an entity referenced by a previous revision?
14:22symbioquine[m]I'm guessing not
14:23mstenta[m]The only protection we have against deletion is from www.drupal.org/project/entity_reference_
14:23mstenta[m]So it depends on that... I kinda suspect it does not protect against this particular case
14:23symbioquine[m]All kinds of things get messy if you're trying to ensure all possible combinations of revision reversion are valid/possible too 🧐
14:24mstenta[m]Yes true... related: github.com/farmOS/farmOS/pull/1004
14:24mstenta[m]We've essentially disabled reverting revisions
14:24mstenta[m](in 4.x)
14:25symbioquine[m]Did reverting create a new revision (like in Git)?
14:26symbioquine[m]Or did it just adjust the "pointers" so the old revision was the current one?
14:26symbioquine[m](Sorry if this is explained in the issue)
14:26mstenta[m]Hmm good question... I forget, but yes I think it creates a new revision?
14:27mstenta[m]That issue was specifically about how reverting revisions could create invalid entities... so I don't know if we were worrying about that question specifically
14:27symbioquine[m]mstenta[m]: In that case, then there could be an argument for making it "recursive" in the case of entity references.
14:28mstenta[m]Yea... gets complicated quick
14:28mstenta[m](As with Git... potential for "conflicts"?)
14:28symbioquine[m]I assume it might create a new revision for the (say log) entity, but that could be pointing at old revisions of the related quantities?
14:28symbioquine[m]Oh wait
14:28symbioquine[m]We already have immutable quantities?
14:29mstenta[m]Heh... I think I was just starting to have similar thoughts...
14:29symbioquine[m](sorry just thinking out loud here)
14:29mstenta[m]Can we consider "quantity revisions" essentially the same thing as "immutable quantities"?
14:30mstenta[m](If the revisions themselves are immutable?)
14:32symbioquine[m]I guess so
14:42symbioquine[m]Interesting tidbit: if you want to find your material quantities the query is a little obtuse: example.farm/api/log/input?filter[quanti
14:42symbioquine[m]Took me a while to figure out that .meta.drupal_internal__target_id part.
14:42symbioquine[m]s//`/, s/input/{log_type}/, s//`/
14:47symbioquine[m]gist.github.com/symbioquine/7a67edccd32e
14:49symbioquine[m]Haven't gone down the past revisions rabbit hole yet.
14:51mstenta[m]I think that will just involved querying references in log_revision__quantity
14:51mstenta[m]s/involved/involve/, s//`/, s//`/
14:52mstenta[m]Oh but that's via SQL... not API...
14:52symbioquine[m]Yeah, I haven't done anything yet with revisions via the API...
14:52symbioquine[m]Just looking at www.drupal.org/docs/core-modules-and-the now
14:53mstenta[m]log__quantity table is the link between log and quantity entities, with only the current revision. log_revision__quantity is the same, but has a row for each revision.
14:53*uploaded an image: (41KiB) < matrix.org/oftc/media/v1/media/download/ >
14:57symbioquine[m]I don't see anything like a previous_revision_id field on the entities returned by the API either so I suspect that it's not possible to discover/iterate previous revisions through the API.
14:57mstenta[m]hmm yea I don't think there is
14:58symbioquine[m]Obviously that would also be terribly inefficient too, but just starting with "is it possible"
14:59mstenta[m]I ran into a strange issue with revisions recently that led me to learn some new things about their complexity...
14:59mstenta[m]moreso when content translations are involved...
14:59symbioquine[m]symbioquine[m]: Basically blocked on www.drupal.org/project/drupal/issues/300
15:00mstenta[m]but also that core uses the phrase "default revision" instead of "current revision"
15:00mstenta[m]because revisions are also used for planned updates... when it comes to content moderation, for example
15:00symbioquine[m]Coming back to the use-case of Drupal as a CMS
15:00symbioquine[m]Yeah
15:00mstenta[m](drafting changes to web pages / blog posts /etc)
15:01mstenta[m]and then yea... the whole content translation aspect... each revision can "affect" translations or not...
15:01mstenta[m]thankfully we don't have to worry about that dimension in farmOS (we only care about interface and config translation in the core farm_l10n module... not content translation)
15:01mstenta[m]But maybe worth seeing this: github.com/farmOS/farmOS/pull/1041
15:02mstenta[m]That was my recent rabbit hole 😅
15:08symbioquine[m]<mstenta[m]> "But maybe worth seeing this..." <- Seems like a bit of a hack to keep using that revisions UI if the intent is that it's only meant to show revisions that have translatable changes - when we'll never have translatable (content) changes.
15:08symbioquine[m]But probably a reasonable move short-term at least.
15:09symbioquine[m]s/short-term/to/, s/at/mark/, s/least/them as translatable/
15:09symbioquine[m]It's surprising that the UI has that condition though...
15:10mstenta[m]My reasoning is: if we don't use content translations, then ALL revisions should be displayed.
15:10mstenta[m]None should be filtered.
15:10symbioquine[m]I'm imagining even in the CMS case that you might have an "article photos" field that's not translatable, but you'd still want to be able to manage the revisions for the article when those photos change.
15:10symbioquine[m]but if I'm understanding correctly, that's not supported by Drupal.
15:10mstenta[m]IMO it's a bug that it won't show the "current revision" if it ends up marked as "not affecting translation"
15:11mstenta[m]We don
15:12mstenta[m]Yea, I get the sense that some of this logic is just historical baggage
15:12mstenta[m]And for our use case it doesn't make sense
15:12mstenta[m]I don't see any reason to hide revisions.
15:12mstenta[m]If we don't want certain things to be saved as revisions, that's a separate issue.
15:12mstenta[m]But if we do save revisions, they should show on that page.
15:13symbioquine[m]Maybe there's some use-case where untranslatable field changes cause a lot of spurious revisions?
15:13mstenta[m]That would be a separate issue too IMO
15:13mstenta[m]If a revision is saved in the database, I want to see it in the UI
15:14symbioquine[m]Yeah, seems reasonable
15:14mstenta[m]But yea... that is the downside of this change... we may all of a sudden find a lot of extra revisions are being created
15:14mstenta[m]But that's probably a good thing in the long run, because we can investigate why
15:14mstenta[m]Right now, they may be happening and we just don't know it
15:15symbioquine[m]Yeah, I doubt it will be an issue for our use-case. Just trying to imagine a reasonable explanation for why you'd want that logic in the "CMS for a website" use-case.
15:16mstenta[m]Yea... from what I've gathered, it's basically:
15:17mstenta[m]"I am looking at the english version of this node, so only show me the revisions that affect the english version"
15:18symbioquine[m]weird
15:18symbioquine[m]Seems like you'd just want tabs for each language or something
15:18mstenta[m]And then if you change to the french version, it would only show the ones that affect french.
15:18symbioquine[m]I guess
15:18mstenta[m]Yea... I think @catch proposed that exact solution...
15:18mstenta[m](core maintainer)
15:19mstenta[m]> Overall I think the revision tab should show all edits to a node regardless of affected language. For example how else would you undo adding a translation except reverting to the revision just before? We could then have a per-language filter on the page to show only affected languages. Or two tab
15:19mstenta[m]www.drupal.org/project/drupal/issues/272
15:20symbioquine[m]Left a comment on github.com/farmOS/farmOS/pull/1041
15:25mstenta[m]Thanks! Good point... pushing fixup...

< 302026-01-31⋏01 >