Bug 432957

Summary: Some tags appear beneath "People" parent tag in People view/panel
Product: [Applications] digikam Reporter: José Oliver-Didier <jose_oliver>
Component: Faces-WorkflowAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: metzpinguin
Priority: NOR    
Version: 7.2.0   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed In: 7.2.0
Sentry Crash Report:
Attachments: People View with "People" parent tag
Sample Image
DebugView logs

Description José Oliver-Didier 2021-02-15 02:13:38 UTC
Created attachment 135688 [details]
People View with "People" parent tag

SUMMARY
Some tags appear beneath "People" parent tag in People view/panel

STEPS TO REPRODUCE
1. Clean install of 7.2.0-rc (ffbcb5f3) 
2. Run Face Detection and Recognition
3. Open "People" view

OBSERVED RESULT
- Refer to attached screenshot.
- Noticed in People view there is a parent tag (with face icon) named "People" with Unconfirmed, Unknown and Ignored tags as well as names underneath. Did not see this on prior builds. There are also names in the root (not under the "People" tag). 
- I attempted to move some of the tags under People but they reappear under the root when re-launching digiKam.
- Installed latest 2/12/2021 (de41d0b2) build and issue still persists.

EXPECTED RESULT
- Did not notice this behavior in prior builds. 
- No "People" parent tag, simply the people names.

SOFTWARE/OS VERSIONS
Windows 10
Comment 1 Maik Qualmann 2021-02-15 05:28:10 UTC
The people parent tag is by design, it has always been there. The people tag is created automatically if it doesn't exist. If a parent tag exists that has most of the face tags under it, it will not be created. You can move the face tags outside of the people tag to the people tag. This people tag has been discussed for a long time and we have some bug reports about it.

Maik
Comment 2 Maik Qualmann 2021-02-15 06:54:28 UTC
One more explanation and I've read your post in user list.

The People Tag was created to keep the tags in order. The standard does not provide a path for face tags. Therefore, found face tags from digiKam are tried to combine them under the people tag. This does not always work, if the scanner scans images first and keywords contain the names of later face tags, these are created outside of the people tag.

In any case, you can move face tags to the people tag (drop them on people tag and choose move). If this does not work, your database tags tree is corrupted...

Maik
Comment 3 José Oliver-Didier 2021-02-15 08:35:20 UTC
Thanks Maik.

Moving the tags within the "People" view as well as using the Tag Manager, but when I restart digiKam they returned to the previous locations.

Typically, I do not store people's names in my tags/keywords- only in MS Windows Photo Gallery People Tags. However, I discovered that some of the affected photos had tags in the tag/keyword metadata. I deleted these tags in Windows Photo Gallery and moved the tags in digiKam again and this time it worked. digiKam moved them to its People/<name goes here> structure.

Could it be that given I do not have the setting enabled in digiKam to write the metadata back to the file that digiKam re-reads the metadata on restart and gives precedent to the file metadata? I will do some testing around this.
Comment 4 José Oliver-Didier 2021-02-15 15:12:29 UTC
I take my previous comment back, after another restart of digiKam the tags returned back to the previous locations not under the "People" parent tag.
Comment 5 José Oliver-Didier 2021-02-15 16:22:17 UTC
Created attachment 135703 [details]
Sample Image

I did a clean install with a clean MySQL db and narrowed the steps to reproduce this issue.

1. Load attached sample image into digiKam Album - this sample image has a MS WPG People Tag "Albert Einstein" as well a keyword/tag "Albert Einstein".
2. Note people tag "Albert Einstein" created below special "People" tag
3. Move "Albert Einstein" tag beneath "People" tag
4. Close digiKam
5. Open digiKam

Encountered Behavior:
- Tag return to previous state, at the same level as "People" tag
Comment 6 Maik Qualmann 2021-02-15 17:45:46 UTC
No, the problem definitely does not occur here, also MySQL tested. Install Microsoft's DebugView, activate the debug environment variable and post the log if you move the tag.
DebugView is described here: https://www.digikam.org/contribute/

Maik
Comment 7 Maik Qualmann 2021-02-15 21:05:05 UTC
Do you use the internal MySQL server?

Maik
Comment 8 Maik Qualmann 2021-02-15 22:05:55 UTC
Git commit 8255cb9325deec0a9c95c3621266e536981a2e68 by Maik Qualmann.
Committed on 15/02/2021 at 22:04.
Pushed by mqualmann into branch 'master'.

use "mysqladmin shutdown" to stop MySQL server
The call via terminate() does not work for Windows console programs.
With  kill() at end, so we have data loss in the database under Windows.

M  +21   -0    core/libs/database/server/databaseserver.cpp

https://invent.kde.org/graphics/digikam/commit/8255cb9325deec0a9c95c3621266e536981a2e68
Comment 9 José Oliver-Didier 2021-02-16 01:00:07 UTC
I am using Remote Server (MySQL). Based on your recent comment seems you managed to stomp out the bug. Go Maik!

Looking forward to the next available rc build with the fix to test it out.
Comment 10 Maik Qualmann 2021-02-16 06:48:58 UTC
No, the last patch tries to fix the problem with the internal MySQL server, which is completely managed by digiKam, which results in destroyed database tables. The problem does not affect an external MySQL server. I need the DebugView log from comment 6.

Maik
Comment 11 José Oliver-Didier 2021-02-16 12:43:27 UTC
Created attachment 135719 [details]
DebugView logs

Attaching DebugView Logs

- digilog_move_tag.txt - Opening Digikam, moving "Albert Einstein" tag to people tag in Tag View.
- digilog_move_people_tag.txt - Opening Digikam, moving "Albert Einstein" tag to people tag in People View.
Comment 12 Maik Qualmann 2021-02-16 12:55:01 UTC
I already suspected that something is wrong with your database, namely with the new triggers for the TagsTree. What are you using, MySQL or MariaDB? Which MySQL Server Version? It looks like the TagsTree doesn't exist, did you update or re-create the database? The fact is, with this malfunction, the tags management will be not work.

Maik
Comment 13 Maik Qualmann 2021-02-16 13:11:15 UTC
According to the error message, it is MySQL. That will be difficult because we are only testing with MariaDB and MySQL is no longer available as a package.

Maik
Comment 14 José Oliver-Didier 2021-02-16 14:36:21 UTC
MySQL 8.0.23

I first came accross this issue when I created the MySQL db, I deleted it and recreated the database to try to narrow this issue down and it still occurs.
Comment 15 José Oliver-Didier 2021-02-16 17:18:52 UTC
Yes, I can confirm that the issue also affects "regular" tags which cannot be moved either.
Comment 16 José Oliver-Didier 2021-02-16 17:32:50 UTC
I installed MariaDB and was able to move the tags into the People tag. Closing and re-opening Digikam, and the changes persists, confirming the functionality worked as expected. So it may seem to be an issue with MySQL in Windows.
Comment 17 Maik Qualmann 2021-02-16 18:28:04 UTC
Git commit 1d23c88ca41660d548e2bdf2136c9d4bfda5cbd3 by Maik Qualmann.
Committed on 16/02/2021 at 18:26.
Pushed by mqualmann into branch 'master'.

wrap in SELECT clause for MySQL

M  +10   -6    core/data/database/dbconfig.xml.cmake.in

https://invent.kde.org/graphics/digikam/commit/1d23c88ca41660d548e2bdf2136c9d4bfda5cbd3
Comment 18 Maik Qualmann 2021-02-16 18:32:37 UTC
The problem is MySQL. With DELETE it cannot read from the same table in the WHERE clause. Please test the change, if it is available with MySQL, whether the moving of tags works there as well. A new DB must be created.

Maik
Comment 19 Maik Qualmann 2021-02-17 06:52:21 UTC
Trigger now works fine on MySQL-8, tested in a Windows 10 VM.

Maik
Comment 20 José Oliver-Didier 2021-02-17 12:40:41 UTC
Fixed: Able to move tags, changes persist after closing and re-opening digiKam.
Tested on 7.2.0-rc (46fd680f) 2/16/2021 build with MySQL 8.0.23 on Windows 10.