Bug 18131 - Bug #3096 returns
: Bug #3096 returns
Status: RESOLVED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: Scanner
: 7.9.x
: PC Linux (other)
: -- normal (vote)
: 7.9.x
Assigned To: Michael Herger
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-04-27 10:36 UTC by Tim Passingham
Modified: 2015-05-13 10:55 UTC (History)
1 user (show)

See Also:
Category: ---


Attachments
A patch to re-fix bug #3096 (123 bytes, patch)
2015-04-28 07:19 UTC, Tim Passingham
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Passingham 2015-04-27 10:36:37 UTC
Bug fix #3096 at line 155 in Contributor.pm no longer works.  It is currently:

[code]
			# Bug 3069: update the namesort only if it's different than namesearch
			if ( $search ne $sort ) {
				$sth = $dbh->prepare_cached('UPDATE contributors SET namesort = ? WHERE id = ?');
				$sth->execute( $sort, $id );
			}
[/code]
The problem is that at some point, the sort form was extended to included accented characters (in lower case) whereas the search form never includes accents (although the characters that are accented in the sort form are in lower case).

So for accented default sort forms $search is always 'ne' $sort.  This means that perfectly good sort forms derived from ArtistSort get overwritten when, for instance, an Artist is also a Composer or Conductor and brings a default sort form.  This is was the original good bug fix was meant to do.

I did a test run with a 'bodge' to prove my theory, and it worked.  I just did:
[code]
    if ( substr($search,0,3) ne substr($sort,0,3) ) {
[/code]
On the basis that for most of my problem artists the accents are later in the name.

What is needed is a proper fix knowing how and why the default sort and search forms are different for accented names, and a function to make the comparison work properly.  I thought of trying 'unidecode' but my Perl knowledge, and multi-language unicode knowledge, are both close to zero. so I thought better of it.

Without this fix, Artist and AlbumArtist menus in LMS are in a random order for many of my artists, and very frustrating to try and use.
Comment 1 Tim Passingham 2015-04-27 16:33:03 UTC
I've now tested what I believe is a 'correct' and self-consistent fix taht shouldn't cause any grief to anyone.  The offending line in my Contributor.pm is now:

[code]
  if ( $search ne Slim::Utils::Unicode::utf8toLatin1Transliterate($sort) ) {
[/code]

I got the function from looking at how namesearch ($search) is derived and applying the same function to namesort ($sort).
Comment 2 Tim Passingham 2015-04-27 19:07:21 UTC
I now believe this problem was introduced earlier than I thought, with the fix for #16956 in Text.pm and the call from Contributor.pm to remove accents from the namesearch field.  My proposed fix should sort it.

I know it may seem trivial, but 'tis a real nuisance for me, and the fix is logical and simple.
Comment 3 Tim Passingham 2015-04-28 07:19:24 UTC
Created attachment 7740 [details]
A patch to re-fix  bug #3096

A diff file is attached for linux/ubuntu

patch /usr/share/perl5/Slim/Schema/Contributor.pm
Comment 4 Tim Passingham 2015-04-28 07:20:34 UTC
Sorry, the line should read:

patch /usr/share/perl5/Slim/Schema/Contributor.pm Contributor.diff

(I wish I could edit comments....)
Comment 5 Tim Passingham 2015-04-29 21:33:27 UTC
Just a note to say that this fix resolves a problem when:

either LMS does not support ComposerSort, ConductorSort, BandSort etc (as is the case unless #18096 is accepted and implemented)

or there are no (or only partial) ComposerSort, ConductorSort, BandSort etc tags in the music files (regardless of LMS support for such tags)
Comment 6 Michael Herger 2015-05-12 09:58:09 UTC
commit f590592f7d385de3ac5064d89ed26ca45eb82e6d
Comment 7 Tim Passingham 2015-05-12 09:59:49 UTC
Michael - did anyone ever tell you you're a star?  

Thanks.
Comment 8 Tim Passingham 2015-05-13 10:55:30 UTC
Re-tested in Logitech Media Server Version: 7.9.0 - 1431440256 @ Wed May 13 04:05:18 UTC 2015.

Fixed.  Thanks.