Bug 423334 - Adding a "pure" tag group to another tag group doesn't work as expected
Summary: Adding a "pure" tag group to another tag group doesn't work as expected
Status: RESOLVED FIXED
Alias: None
Product: kphotoalbum
Classification: Applications
Component: XML backend (show other bugs)
Version: GIT master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KPhotoAlbum Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-21 21:48 UTC by Johannes Zarl-Zierl
Modified: 2020-06-22 00:01 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Zarl-Zierl 2020-06-21 21:48:12 UTC
SUMMARY
When a "pure" tag group is added (i.e. a tag group that is not also used as a tag on some image/video), and then this group is added to another group, this information is lost if the compressed index.xml file format is used.

The problem is that the tag group is stored under the `<member-groups>` node in index.xml, but not as an independent node below the respective `<Category>` node. Therefore, no numeric id is assigned to the group and when it is added to another group, an ephemeral numeric id for the group is stored.
When the index.xml file is read again, kphotoalbum throws away the invalid id.

STEPS TO REPRODUCE
1. Open kphotoalbum --demo
2. Open the annotation dialog for an image (e.g. "new_wave")
3. Right-click on tag "Esbjerg"
4. Click "Tag groups | Add this tag to a new tag group..."
5. Enter "test"
6. Right-click on tag "test"
7. Click "Tag groups | USA"
8. Save database and exit without deleting the demo database

OBSERVED RESULT
Examining the `index.xml` file, member group "USA" has a member "11", but the category "Places" only has tags with ids 1 to 10.
The tag "test" is only a member group, but not a tag.
When loading this database in kphotoalbum, the tag group "test" is no longer a member of group "USA".

EXPECTED RESULT
There should be a tag node in the category "Places" with name "test" and id 11.
Comment 1 Johannes Zarl-Zierl 2020-06-22 00:01:22 UTC
Git commit 366c46fa04872ccc7becc838fa61e887490d8ecd by Johannes Zarl-Zierl.
Committed on 21/06/2020 at 21:57.
Pushed by johanneszarl into branch 'master'.

Issue diagnostic when invalid id reference is used in member-group.

Note: I also checked that this is the only remaining place in FileReader where
an inconsistency is just ignored by continuing to the next value. So
things as decribed in bug 423334 *should* no longer go unnoticed for
such a long time.

M  +4    -1    XMLDB/FileReader.cpp

https://invent.kde.org/graphics/kphotoalbum/commit/366c46fa04872ccc7becc838fa61e887490d8ecd
Comment 2 Johannes Zarl-Zierl 2020-06-22 00:01:22 UTC
Git commit ab47cb0bf3227458846e019c1cc6b00c131ade19 by Johannes Zarl-Zierl.
Committed on 22/06/2020 at 00:00.
Pushed by johanneszarl into branch 'master'.

Consider MemberMap data when saving categories.

If a tag group is only known in the MemberMap (because it was not used
as a tag on an image or video), then special care is needed when saving
to prevent inconsistent data from being written. See the attached bug
number for an analysis of a possible bug scenario.

M  +1    -0    AnnotationDialog/ListSelect.cpp
M  +4    -12   XMLDB/FileWriter.cpp

https://invent.kde.org/graphics/kphotoalbum/commit/ab47cb0bf3227458846e019c1cc6b00c131ade19