Comments (3)
I'll do a bit of a stream of consciousness as I try to remember how TaxonomyField
s worked, by putting here information I'm gleaning by re-reading the code.
Those IDs (for the terms selected in a TaxonomyField
) are NOT already serialized (for either published and latest versions of a ContentItem) in the StringFieldIndexRecord
, that is used for queries/projections. OnLoading
the terms in the field are populated (in its LazyField) off the records for the TermsPart
for the ContentItem. Those records are also used for projections. This is unlike, for example, ContentPickerField
.
ITaxonomyService.UpdateTerms
: given the list of terms we selected, we want this method to make sure that the TermsPart
for the ContentItem we are processing ends up having, for a specific field, only TermContentItem
s for those terms. Moreover, this method should take all the terms that were unselected to fire off a processing task. Currently, that doesn't work properly, to be entirely honest:
- Start with a ContentItem with selected Term 'A'. Publish it.
- Change selected terms (e.g. unselect 'A' and select 'B'). Save the content as a Draft (don't publish it).
The records are updated anyway, and when displaying the content it's going to show the information for the DraftTaxonomyField
.
It's possible that one way to fix this would be to make the TermsPartRecord
a ContentPartVersionRecord
. That would also take care of the need to keep track of the changes to the list of terms in the UpdateTerms
method, since we'd have new records for the new version. This wouldn't be adding more stuff to the DB than it is now on update, but it would not delete TermContentItem
records attached to previous versions: fewer operations, but in the end a larger table.
It would complicate the step done OnPublished
to call the task that counts selected ContentItems for each term, but only slightly: we would compare the current version with the previous one to also account for unselected terms, rather than have a separate invocation of the task in the UpdateTerms
method.
That "new" versioned part could on principle also have the Ids in its infoset, but it would have to query for all corresponding records anyway, and we wouldn't need to compare the list of Ids to a previous version.
from orchard.
I wasn't really considering versioning, but I agree that it's weird that saving a draft item with different terms selected is immediately reflected in the published version as well.
My immediate concern here is that DB changes happen even when they aren't needed: When you save a Taxonomy Field without changes, the DB operations play out as if you unselected all the terms, saved it and then re-selected the same terms and saved it again, which is wasteful.
from orchard.
Yes. On the other hand, if we moved to a versioned record, that's sort of the default behaviour: the records for the new version, if no change has happened, end up being duplicates of the previous ones (except for the relevant Ids). But we would not be deleting a record just to add it back.
from orchard.
Related Issues (20)
- Migrate CI builds from TeamCity to GitHub Actions HOT 4
- Merge 1.10.x into dev
- Fixing build and tests on 1.10.x and dev HOT 14
- Perf: GetMany doesn't use ContentManagerSession HOT 7
- INavigationFilter implementations should not repeat queries HOT 3
- Upgrade Orchard.Email from using SmtpClient HOT 2
- Back LocalizationPart's LazyFields with Infoset HOT 5
- Safe handle has been closed Exception
- Impossible to start a new instance on an existing SQL Server Database HOT 3
- Double model error displayed for required MediaLibraryPickerFields HOT 1
- filterTaxonomyCulture function isn't unique if multiple TaxonomyFields are inside the content
- Should GetCultureByName be cached
- GetUser is called several times per pageload HOT 2
- Consolidate Owin package versions on dev
- Adding scale parameter to ResizeMediaUrl function HOT 1
- When saving the Ssl Settings, the update does not evict the corresponding cache entry
- Missing maximum length setting for TextField and TitlePart
- Orchard.Layouts: the toolbox is not usable HOT 1
- Error during translation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from orchard.