Bug 415415 - Renaming tag groups can produce tags with id=0
Summary: Renaming tag groups can produce tags with id=0
Status: RESOLVED FIXED
Alias: None
Product: kphotoalbum
Classification: Applications
Component: XML backend (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KPhotoAlbum Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-20 23:32 UTC by Johannes Zarl-Zierl
Modified: 2020-01-12 00:06 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 5.6


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Zarl-Zierl 2019-12-20 23:32:27 UTC
SUMMARY
Renaming tag groups can produce tags with id=0, which is a problem not just because most code assumes that id != 0, but because it can lead to losing tag data.
Especially, if more than one tag gets assigned the id=0 due to this bug, an automatic recovery is not possible.

STEPS TO REPRODUCE
1. Create a new tag group under under an existing tag group.  For
   example, with the demo database, create a tag group named "dk"
   under Places->Denmark.
2. Rename said tag group.
3. Save.  The new group will have ID 0, accompanied by this message:
   kphotoalbum.XMLDB: Member "dk1" in group "Places" -> "Denmark" has
   no id!

Note that renaming an existing tag group, or creating one at top level
(e. g. under Places) does not trigger this.

The bug was at least present since mid 2017.

Note:
 - Thanks to Robert Krawitz for discovering bug and fixing the cause of it!
 - This bug report was created after the fact for documentation purposes.
Comment 1 Johannes Zarl-Zierl 2019-12-20 23:35:17 UTC
The root cause for this bug was fixed by commit 059b6934:
https://cgit.kde.org/kphotoalbum.git/commit/?id=059b6934fad3876ae8b2d1cfd8fc25e72698a584
Comment 2 Johannes Zarl-Zierl 2019-12-22 00:20:04 UTC
Git commit 8a6df8d7e3bfb92c86149bd233edfe15c1ecea55 by Johannes Zarl-Zierl.
Committed on 22/12/2019 at 00:12.
Pushed by johanneszarl into branch 'master'.

Try fixing tags with id=0

When tags with the invalid id "0" are encountered in the index.xml file,
KPhotoAlbum now tries to automatically fix them, if possible:

1. If only a single tag in a category has been assigned a zero id,
   a proper id is assigned.
2. If multiple tags in a category have been assigned a zero id,
   KPhotoAlbum can not know which tag was originally assigned to the
   image.
   In this case, the affected images are tagged with all possible tags
   plus a marker tag.

M  +20   -2    XMLDB/Database.cpp
M  +25   -1    XMLDB/FileReader.cpp
M  +13   -0    XMLDB/FileReader.h
M  +25   -5    XMLDB/XMLCategory.cpp
M  +20   -2    XMLDB/XMLCategory.h

https://commits.kde.org/kphotoalbum/8a6df8d7e3bfb92c86149bd233edfe15c1ecea55
Comment 3 Johannes Zarl-Zierl 2020-01-08 22:03:03 UTC
Git commit 93dd93f195c03d6cb4bcab0fce7357f6161fe7e9 by Johannes Zarl-Zierl.
Committed on 08/01/2020 at 21:59.
Pushed by johanneszarl into branch 'master'.

Display message when manual repair is needed

In addition to the log messages, display a GUI message when categories
with id=0 were found in the database and some of them could not be
repaired automatically (i.e. more than one tag with id=0 in the same
category).

M  +25   -1    XMLDB/FileReader.cpp

https://commits.kde.org/kphotoalbum/93dd93f195c03d6cb4bcab0fce7357f6161fe7e9
Comment 4 Johannes Zarl-Zierl 2020-01-12 00:06:09 UTC
Git commit 522158ef7e8ac3642e374fe7ff5cebb5cf43a294 by Johannes Zarl-Zierl.
Committed on 12/01/2020 at 00:02.
Pushed by johanneszarl into branch 'master'.

Changelog for id=0 issue
FIXED-IN: 5.6

M  +5    -0    ChangeLog

https://commits.kde.org/kphotoalbum/522158ef7e8ac3642e374fe7ff5cebb5cf43a294