Skip to content

Get Correct Content version on second pass events.#821

Merged
KevinJump merged 8 commits into
v16/mainfrom
v16/save-update-fix
Oct 7, 2025
Merged

Get Correct Content version on second pass events.#821
KevinJump merged 8 commits into
v16/mainfrom
v16/save-update-fix

Conversation

@KevinJump

@KevinJump KevinJump commented Oct 7, 2025

Copy link
Copy Markdown
Owner

This is a little be of a sticking plaster on how the ContentService is updating it's version of the content as we progress (and save/publish it). We really need to return the new version of the item in the result of a couple of functions so it can make it back into the in memory array of items we then use in the second pass.

at the moment we are reloading the version if the second pass needs to then save it, in theory if something is trashed, with a schedule and not in the right order, that means we load it three times, but that is preferable to loading ever single content item on a second pass that we might not then need.

the longer term fix is to capture the new version at the place we save/publish it in the first pass, and then we won't have to reload things all the time. .

@KevinJump KevinJump requested a review from Copilot October 7, 2025 15:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures operations use the latest persisted version of content items during sync, reducing stale state issues between passes.

  • Fetch and act on the latest item instance via GetByKey before mutating sort order, moving/restoring, and persisting schedules.
  • Align second-pass save to a single-item API SaveItemAsync.
  • Minor refactors to reduce redundant loads during second pass while keeping behavior consistent.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
uSync.Core/Serialization/Serializers/ContentSerializerBase.cs Use latest item for sort order and trash/restore operations to avoid stale references.
uSync.Core/Serialization/Serializers/ContentSerializer.cs Persist schedules on the latest item instance to reflect current version.
uSync.BackOffice/SyncHandlers/SyncHandlerRoot.cs Switch to SaveItemAsync for second-pass persistence of a single changed item.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread uSync.Core/Serialization/Serializers/ContentSerializerBase.cs Outdated
Comment thread uSync.Core/Serialization/Serializers/ContentSerializerBase.cs Outdated
Comment thread uSync.Core/Serialization/Serializers/ContentSerializerBase.cs Outdated
Comment thread uSync.Core/Serialization/Serializers/ContentSerializerBase.cs Outdated
@KevinJump KevinJump changed the title Update the version when we sort it, Get Correct Content version on second pass events. Oct 7, 2025
KevinJump and others added 6 commits October 7, 2025 16:20
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@KevinJump KevinJump merged commit 63dc30d into v16/main Oct 7, 2025
1 check passed
@KevinJump KevinJump deleted the v16/save-update-fix branch October 8, 2025 08:38
alexsee pushed a commit to alexsee/umbraco-container that referenced this pull request Dec 6, 2025
[//]: # (dependabot-start)
⚠️  **Dependabot is rebasing this PR** ⚠️ 

Rebasing might not happen immediately, so don't worry if this takes some
time.

Note: if you make any changes to this PR yourself, they will take
precedence over the rebase.

---

[//]: # (dependabot-end)

Updated [uSync](https://github.com/KevinJump/uSync) from 16.0.5 to
16.1.0.

<details>
<summary>Release notes</summary>

_Sourced from [uSync's
releases](https://github.com/KevinJump/uSync/releases)._

## 16.1.0

This is a minor update to uSync for Umbraco v16, it contains feature
updates to how BlockList/Grid merges are reported and the ability to
merge uSync files for multiple items into single files so they can be
read in one block from the server (no UI for this, feature will likely
be enabled via the uSync.Cli).

## What's Changed
* V16/block converters two by @​KevinJump in
KevinJump/uSync#822
* pass latest content version between passes. by @​KevinJump in
KevinJump/uSync#823
* V16/firstboot on startup conflict fix by @​KevinJump in
KevinJump/uSync#824
* Add operation security filter so swagger auth is allowed. by
@​KevinJump in KevinJump/uSync#825
* Share second pass actions across commonn IContentBase objects by
@​KevinJump in KevinJump/uSync#826
* Rix #​827 - Removal's code was trying to modify array inside loop of
array by @​KevinJump in KevinJump/uSync#828
* V16/multiple nodes per file by @​KevinJump in
KevinJump/uSync#829

**Full Changelog**:
KevinJump/uSync@v16.0.8...v16.1.0

This will be the last 'feature' release of uSync for Umbraco v16 as we
move on to supporting and targeting Umbraco v17 (see
https://docs.jumoo.co.uk/SupportLifecycles#Short-Term-Support-STS-Releases)

## 16.0.8

This is a patch release of uSync for Umbraco, it contains some fixes
issues around imports on startup and UI messages.

## What's Changed
* update package.json dependencies. by @​KevinJump in
KevinJump/uSync#819
* Offer more granular updates to the ordering process by @​KevinJump in
KevinJump/uSync#820
* Get Correct Content version on second pass events. by @​KevinJump in
KevinJump/uSync#821


**Full Changelog**:
KevinJump/uSync@v16.0.7...v16.0.8

## 16.0.7

This is a patch release for uSync for Umbraco v16 - it contains some
fixes and updates based on reported issues.

## What's Changed
* Some string changes to reduce some allocations here and there. by
@​KevinJump in KevinJump/uSync#808
* Fix #​803 (again) ensure the self referencing nodes are removed by
@​KevinJump in KevinJump/uSync#809
* only check for legacy when the default folder hasn't been changed. by
@​KevinJump in KevinJump/uSync#810
* V16/dashboard tweaks by @​KevinJump in
KevinJump/uSync#811
* normalize string media paths into JSON croppers for consistancy. by
@​KevinJump in KevinJump/uSync#812
* Fix: Compiled Views Content by @​KevinJump in
KevinJump/uSync#813
* move away from uui-table-row by @​KevinJump in
KevinJump/uSync#814
* v16 fix of #​815 by @​KevinJump in
KevinJump/uSync#818


**Full Changelog**:
KevinJump/uSync@v16.0.5...v16.0.7

Commits viewable in [compare
view](KevinJump/uSync@v16.0.5...v16.1.0).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=uSync&package-manager=nuget&previous-version=16.0.5&new-version=16.1.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

You can trigger a rebase of this PR by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

> **Note**
> Automatic rebases have been disabled on this pull request as it has
been open for over 30 days.

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants