Bug 6092

Summary: default sort field and order when syspref are NULL
Product: Koha Reporter: Fridolin Somers <fridolin.somers>
Component: System AdministrationAssignee: Fridolin Somers <fridolin.somers>
Status: CLOSED FIXED QA Contact: Bugs List <koha-bugs>
Severity: normal    
Priority: PATCH-Sent (DO NOT USE) CC: chris, gmcharlt, katrin.fischer
Version: Main   
Hardware: All   
OS: All   
See Also: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=8012
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Proposed patch
BUG6092 default sort field and order when syspref are NULL

Description Fridolin Somers 2011-04-06 14:42:09 UTC
Database installer "en" and others, initialize sysprefs (OPAC)defaultSortField and (OPAC)defaultSortOrder with NULL.

I added "relevance" and "dsc" as default values in .pref file and in perl pages.
Because it is the natural sort order of search results.

I think it's the best way to avoid bugs.

Regards,
Comment 1 Fridolin Somers 2011-04-06 14:45:17 UTC Comment hidden (obsolete)
Comment 2 Chris Cormack 2011-05-17 08:04:46 UTC
Created attachment 4139 [details] [review]
BUG6092 default sort field and order when syspref are NULL

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Comment 3 Fridolin Somers 2011-05-17 09:14:21 UTC
(In reply to comment #2)
> Created attachment 4139 [details] [review]
> BUG6092 default sort field and order when syspref are NULL
> 
> Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Hie,

Is the first patch obsolete ?
I bet yes.
Comment 4 Paul Poulain 2011-08-10 09:39:29 UTC
QA comment

This patch does not apply anymore. I think it must be completly rewritten. The conflict says :
<<<<<<< HEAD
    if (   C4::Context->preference('OPACdefaultSortField')
        && C4::Context->preference('OPACdefaultSortOrder') ) {
        my $default_sort_by =
            C4::Context->preference('defaultSortField') . '_'
          . C4::Context->preference('defaultSortOrder');
        $template->param( $default_sort_by => 1 );
    }
=======
    $template->param($default_sort_by => 1);
>>>>>>> BUG6092 default sort field and order when syspref are NULL

=> the default sort order is set only if the syspref have been set, so the 
my $default_sort_field = C4::Context->preference('defaultSortField') || 'relevance'; # relevance field by default
my $default_sort_order = C4::Context->preference('defaultSortOrder') || 'dsc'; # decreasing order by default
my $default_sort_by = $default_sort_field.'_'.$default_sort_order;

will do nothing.
Comment 5 Katrin Fischer 2012-06-11 15:36:50 UTC
I think this still needs a fix:

 157 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('defaultSortField',NULL,'Specify the default field used for sorting','relevance|popularity|call_number|pubdate|acqdate|title|author','Choice');
 158 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('defaultSortOrder',NULL,'Specify the default sort order','asc|dsc|az|za','Choice');
Comment 6 Katrin Fischer 2012-06-11 15:49:32 UTC
Fridolyn, could you perhaps resubmit this patch with changes to the syspref.sql file?
Comment 7 Chris Cormack 2013-01-01 23:46:35 UTC
Fixed by another patch