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

BUGFIX - Correct issues in delete items in list #4230

Merged

Conversation

corentin-soriano
Copy link
Contributor

@corentin-soriano corentin-soriano commented Jun 24, 2024

Commit "Avoid duplicate items in list after a delete":
image

Commit "Delete by id instead of key to gain reliability": #4224

  • The item key can be duplicated in database.
  • The imported items all have a key of -1.
  • The item id is the primary key, so it can't be null or duplicate. It's more reliable.

image

@corentin-soriano corentin-soriano changed the title Correct issues in delete items in list BUGFIX - Correct issues in delete items in list Jun 24, 2024
@nilsteampassnet nilsteampassnet merged commit f1acaa1 into nilsteampassnet:master Aug 25, 2024
2 of 3 checks passed
@nilsteampassnet
Copy link
Owner

Thank you

@FengZh61
Copy link
Contributor

FengZh61 commented Sep 2, 2024

I also encountered this problem in version 3.1.2.45, when I imported the data through the csv file, the value of item_key was -1, and I also found that the value of created_at was null, I solved the problem of the value of item_key being -1 by modifying the incoming sql, but from the data structure of the datasheet, the value of item_key was not guaranteed unique, if item_key is duplicated, will I encounter problems in other scenarios?

The fix to avoid duplicate items in the list after deletion is great!

@corentin-soriano
Copy link
Contributor Author

@FengZh61
Copy link
Contributor

@FengZh61 My bad, little mistake in https://github.com/nilsteampassnet/TeamPass/pull/4273/files#diff-1139f18c144af50ac2f79fa33a40e72d5209d055b98c04ea5351f7832e76cd9a

Can you test this fix? #4322

I'm not very proficient with git, I'll post my modifications, feel free to discuss.

  • sources/import.queries.php#L378
    Add the following fields
 'item_key' => uniqidReal(50),
 'created_at' => time(),

The purpose of this part of the modification is to assign a value to the item_key so that it will not be -1, and to assign a value to the creation time, which is null by default.

  • sources/items.queries.php#L2215
    Add the following fields
 $aSet = array();
 //$aSet['created_at'] = time();
       foreach ($originalRecord as $key => $value) {
             $aSet['created_at'] = time();
             $aSet['item_key'] = uniqidReal(50);
             if ($key === 'id_tree') {

This part of the modification is mainly to avoid the problem of duplicate item_key when copying the item.

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.

3 participants