<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/4.6.6">
</HEAD>
<BODY>
Hi Robin,<BR>
<BR>
I think I have got to the bottom of this issue and it is a fairly simple fix but was an absolute pain to diagnose.&nbsp; Hopefully this will fix your problem as well.<BR>
<BR>
It looks like MariaDB does not sort sub-queries which is needed by EPrints to reorder an EPrints::List.&nbsp; This is how the ordering of the table on the Manage Deposits page is ordered.&nbsp; More detail can be found on this issue on MariaDB at:<BR>
<BR>
<A HREF="https://mariadb.com/kb/en/mariadb/why-is-order-by-in-a-from-subquery-ignored/">https://mariadb.com/kb/en/mariadb/why-is-order-by-in-a-from-subquery-ignored/</A><BR>
<BR>
I am not sure if this is only an issue with MariaDB or whether later versions of MySQL have the same issue.&nbsp; Therefore, even if you are running MySQL it is worth giving my (slightly hacky) fix a try.<BR>
<BR>
Below is a rough diff of what I needed to change in perl_lib/Database/mysql.pm to make things work:<BR>
<BR>
--- mysql.pm        (revision 9244)<BR>
+++ mysql.pm        (working copy)<BR>
@@ -397,7 +397,9 @@<BR>
         $sql .= &quot;($Q_pos, $Q_keyname)&quot;;<BR>
         $sql .= &quot; SELECT <A HREF="mailto:\@i">\@i</A>:=<A HREF="mailto:\@i">\@i</A>+1, $Q_keyname&quot;;<BR>
-        $sql .= &quot; FROM ($select_sql) &quot;.$self-&gt;quote_identifier( &quot;S&quot; );<BR>
+ # MariaDB does not order sub-queries unless limited. Using limit of 2^31-1 in case any system is using a signed 32-bit integer.<BR>
+        my $limit = &quot; LIMIT 2147483647&quot;;<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $limit = &quot;&quot; if $select_sql =~ /LIMIT/;<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $sql .= &quot; FROM ($select_sql$limit) &quot;.$self-&gt;quote_identifier( &quot;S&quot; );<BR>
 <BR>
         $self-&gt;do( $sql );<BR>
 }<BR>
<BR>
Hope this helps,<BR>
<BR>
David Newman<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
On Tue, 2015-09-15 at 19:44 +0100, Adam Field wrote:<BR>
<BLOCKQUOTE TYPE=CITE>
    Oooohhhh, complicated
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    <BR>
    <BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    OK, you'll need to check the user record to see which columns they have turned on, and then order by the first one, as I believe that is the one default ordering applies to.
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    <BR>
    <BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    A better idea, though, would be to figure out what's going on.
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    <BR>
    <BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    Is anyone else on the list experiencing this problem?
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    <BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    --
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    Adam Field
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    Business Relationship Manager and Community Lead<BR>
    EPrints Services
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    <BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    <BLOCKQUOTE TYPE=CITE>
        On 8 Sep 2015, at 14:30, Robin Sylvestre &lt;<A HREF="mailto:robin.sylvestre@polymtl.ca">robin.sylvestre@polymtl.ca</A>&gt; wrote:
    </BLOCKQUOTE>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    <BLOCKQUOTE TYPE=CITE>
        <BR>
    </BLOCKQUOTE>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    <BLOCKQUOTE TYPE=CITE>
        Thank you Adam!<BR>
        <BR>
        I can confirm it works better now, although there is still one thing left. <BR>
        When we get to the &quot;manage deposits&quot; list, it always appears as if sorted by <BR>
        descending eprint ids, regardless of what should be the active column. The <BR>
        list gets sorted correctly only after we click on the column's title.<BR>
        <BR>
        For instance, see the attached screenshots: When the page is loaded <BR>
        (screenshot001) and what it should be (screenshot002).<BR>
        <BR>
        Any ideas?<BR>
        <BR>
        Robin Sylvestre<BR>
        <BR>
        <BR>
        <BR>
        -----Message d'origine-----<BR>
        De : Field A.N. [<A HREF="mailto:af05v@ecs.soton.ac.uk">mailto:af05v@ecs.soton.ac.uk</A>]<BR>
        Envoy&#233; : 7 septembre 2015 06:45<BR>
        &#192; : <A HREF="mailto:eprints-tech@ecs.soton.ac.uk">eprints-tech@ecs.soton.ac.uk</A><BR>
        Objet : [EP-tech] Re: &quot;Manage deposits&quot; list not sorting<BR>
        <BR>
        I've seen this issue before -- in the case I examined, it looked like the <BR>
        _buffer_order parameter was somehow being lost. &nbsp;I managed to get it working <BR>
        with the following code in the Items plugin:<BR>
        <BR>
        in the 'properties_from' function:<BR>
        <BR>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#af05v 20150512 Workaround for immediate solution to lack of <BR>
        ordering<BR>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $order = $session-&gt;param('_buffer_order');<BR>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$self-&gt;{processor}-&gt;{af05v_order} = $order;<BR>
        <BR>
        <BR>
        in the perform_search function:<BR>
        <BR>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $list = $self-&gt;{session}-&gt;current_user-&gt;owned_eprints_list( <BR>
        %$search, # custom_order =&gt; $search-&gt;{order}<BR>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#af05v 20150512 Workaround for immediate solution to lack of <BR>
        ordering<BR>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;custom_order =&gt; $self-&gt;{processor}-&gt;{af05v_order}<BR>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<BR>
        <BR>
        However, I didn't have time to figure out *why* this was happening. &nbsp;Anyone <BR>
        have any ideas?<BR>
        <BR>
        --<BR>
        Adam Field<BR>
        Business Relationship Manager and Community Lead EPrints Services<BR>
        +44 (0)23 8059 8814<BR>
        <BR>
        <BR>
        <BR>
        <BR>
        <BR>
        On 2 Sep 2015, at 17:48, Robin Sylvestre wrote:<BR>
        <BR>
        <BLOCKQUOTE TYPE=CITE>
            Hello fellow EPrinters,<BR>
            <BR>
            Running version 3.3.14, we have noticed a strange behavior on the &#8220;manage <BR>
            deposits&#8221; screen. Items do not sort at all, when clicking on the <BR>
            appropriate column title (see attached screen shots). Nothing changes, <BR>
            only the up/down arrow appears.<BR>
            <BR>
            The strange thing is that the &#8220;revision&#8221; list is not affected by this bug, <BR>
            only the &#8220;deposits&#8221; list.<BR>
            <BR>
            I have tried to do a &#8220;epadmin reorder [archive] eprint&#8221; but that does not <BR>
            correct the problem. Both of our live and test versions have this problem.<BR>
            <BR>
            Did anyone notice a similar bug or has a solution to offer? Thanks!!<BR>
            <BR>
            <BR>
            <BR>
            Robin Sylvestre<BR>
            Technicien en documentation<BR>
            Biblioth&#232;que - Services techniques et syst&#232;mes informatis&#233;s &#201;cole<BR>
            Polytechnique de Montr&#233;al<BR>
            T&#233;l.: 514-340-4711 poste 3743<BR>
            <BR>
            &lt;ScreenShot001.png&gt;&lt;ScreenShot003.png&gt;*** Options:<BR>
            <A HREF="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</A><BR>
            *** Archive: http://www.eprints.org/tech.php/<BR>
            *** EPrints community wiki: http://wiki.eprints.org/<BR>
            *** EPrints developers Forum: http://forum.eprints.org/<BR>
        </BLOCKQUOTE>
        <BR>
        <BR>
        <BR>
        &lt;ScreenShot001.png&gt;&lt;ScreenShot002.png&gt;*** Options: <A HREF="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</A><BR>
        *** Archive: <A HREF="http://www.eprints.org/tech.php/">http://www.eprints.org/tech.php/</A><BR>
        *** EPrints community wiki: <A HREF="http://wiki.eprints.org/">http://wiki.eprints.org/</A><BR>
        *** EPrints developers Forum: <A HREF="http://forum.eprints.org/">http://forum.eprints.org/</A><BR>
        <BR>
    </BLOCKQUOTE>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    <BR>
    <BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<PRE>
*** Options: <A HREF="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</A>
*** Archive: <A HREF="http://www.eprints.org/tech.php/">http://www.eprints.org/tech.php/</A>
*** EPrints community wiki: <A HREF="http://wiki.eprints.org/">http://wiki.eprints.org/</A>
*** EPrints developers Forum: <A HREF="http://forum.eprints.org/">http://forum.eprints.org/</A>
</PRE>
</BLOCKQUOTE>
<BR>
</BODY>
</HTML>