Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tstamp may not be updated after sorting changed because of cut/copy operation #7085

Open
ReneLuecking opened this issue Apr 4, 2024 · 1 comment
Labels
bug up for discussion Issues and PRs which will be discussed in our monthly Mumble calls.
Milestone

Comments

@ReneLuecking
Copy link
Contributor

Affected version(s)

All versions

Description

First of all I'm not sure if this is really considered a bug or working as intended.

I'm using tl_content as an example but in general all tables with pid and sorting are affected.

When moving content elements from one place to another Contao may update the sorting value of surrounding elements which where not explicitly moved. As an example lets say we have an article with 5 content elements in it:

id sorting tstamp type
1 64 1000000000 headline
2 128 1000000000 text
3 129 1000000000 html
4 130 1000000000 image
5 131 1000000000 text

Now I want to move the elements with ID 4 and 5 between 2 and 3. To do this I select ID 4 and 5, click "Cut" and then "Paste after" ID 2. This results in the following data:

id sorting tstamp type
1 64 1000000000 headline
2 128 1000000000 text
3 134 1000000000 html
4 129 1234567890 image
5 130 1234567890 text

ID 4 and 5 have updated sorting values to represent their new position and updated tstamps as I explicitly moved them. ID 3 also has an updated sorting value as it had to move down to make place for ID 4 and 5., BUT ID 3 does NOT have an updated tstamp as it was not moved explicitly.

Depending on the definition you could either say that ID 3 should have a new tstamp, as it has technically changed, but you could also say it should not have a new tstamp as it was not changed by a user.

The reason I even bring this topic up is the following: we have custom code in place to keep two Contao systems in sync. That means if something changes in system 1 it should also get updated in system 2. The tstamp is used to detect and sync any changes, otherwise we would always need to check all database entries for changes, as usually the tstamp gets updated if something changes. Except in this specific case.

I'm really not sure if that is an issue for anyone except me and if it should be changed or not. If it will be changed, as far as I know the following 3 statements in DC_Table would need to also update the tstamp:

$db
->prepare("UPDATE " . $this->strTable . " SET sorting=? WHERE id=?")
->limit(1)
->execute($count++ * 128, $objNewSorting->id);

$db
->prepare("UPDATE " . $this->strTable . " SET sorting=? WHERE id=?")
->execute($count++ * 128, $objNewSorting->id);

$db
->prepare("UPDATE " . $this->strTable . " SET sorting=? WHERE id=?")
->execute($count++ * 128, $objNewSorting->id);

@leofeyer leofeyer added this to the 4.13 milestone Apr 5, 2024
@aschempp aschempp added the up for discussion Issues and PRs which will be discussed in our monthly Mumble calls. label May 27, 2024
@aschempp
Copy link
Member

First of all I'm not sure if this is really considered a bug or working as intended.

Marking this as up-for-discussion because I'm not sure either 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug up for discussion Issues and PRs which will be discussed in our monthly Mumble calls.
Projects
None yet
Development

No branches or pull requests

3 participants