PDA

View Full Version : Odd behaviour from header sort


malum
21st of January 2005 (Fri), 05:51
I have just updated to 1.5 RC4 from 1.3

I notice that if I edit the photo (from EE photo editor) it throws out the order on the list page (which is set to order by header as default)
Anything edited gets added near the bottom (after a refresh) and it's also in the wrong order anywhere else that 'order by header' is selected.

If I edit them all and save them (one at a time) then the correct order is re established.
Anything new added goes in the correct place.

Very odd but I'm sure there is a logical explanation.

By the way.
How much is a liscence and how do I pay you?

(I'd have a big flashing sign everywhere if I were you :D)

Pekka
21st of January 2005 (Fri), 06:36
Can you please explain that again? Give me a step-by-step how to reproduce the problem.

By the way.
How much is a liscence and how do I pay you?

(I'd have a big flashing sign everywhere if I were you
Personal licence is $35. You can use donate link in http://photography-on-the.net/ee/ for the moment, just make sure you mention your name and email in process.

And yes, I have to get acting like a businessman soon :)

malum
21st of January 2005 (Fri), 06:52
Updated from 1.3 to 1.5 RC4 with no problems

On looking at the list by thumbnails 7 in a row or 4 in a row page all the pictures were ordered by their header number (as they should have been)

I then edited the text area of one of the pictures and saved it.

On looking the thumbnail page again I found that this newly edited picture was not in the right order, it was near the bottom of the page when in fact it should have been near the top of the page.

I then edited another picture's text and this picture was also then in the wrong order on the thumnails view page

The only way to get them all in the right sort order again was to go to the photo edit page and save changes for each photo (even if no changes had in fact been made)

Any new pictures added were inserted in the correct place so it's only affecting pictures that were in the database before the upgrade


For example see below (this is a test server which is still showing the behaviour)
I edited photo number 21.3.155 and it is now third from the bottom of the page when it should be first on the list

(edit: removed url for privacy reasons)

This is also the case on another server so it's not just a one off.
I wondered if it was to do with having fullstops in my naming convention.


I hope that makes sense.

Pekka
21st of January 2005 (Fri), 07:54
Why the sorting does not apply first time: I have no clue. If the data is saved in photo editor it does not do it differently each time. I'd suspect MySQL cacheing here. I could not reproduce that problem here.

The sorting you use needs some thought, though. You need to sort by numbers, but the header is text. This is a problem, because MySQL sorts by data type - if it sees data type "text" then it sorts:

002
1
10
2
21.3.155
31.2.459
7.9.56

The parenthesis you use confuses MySQL even more.

There is a way to force MySQL to sort text fields as they were numbers. If you want to enable that, replace in list.php

$order_and_limit_from_sql = "ORDER by " . $sort_row . " " . $order . " " . "LIMIT " . $offset . ", " . $perpage;

with

if ($sort_row == $q1) $sort_row = "({$q1}+0)";
$order_and_limit_from_sql = "ORDER by " . $sort_row . " " . $order . " " . "LIMIT " . $offset . ", " . $perpage;
if ($sort_row == "({$q1}+0)") $sort_row = $q1;

and in photo.php

$order_and_limit_from_sql = "ORDER by " . $sort_row . " " . $order;

with

if ($sort_row == $q1) $sort_row = "({$q1}+0)";
$order_and_limit_from_sql = "ORDER by " . $sort_row . " " . $order;
if ($sort_row == "({$q1}+0)") $sort_row = $q1;

and


$order_and_limit_from_sql = "ORDER by " . $sort_row . " " . $order . " " . "LIMIT " . $centeroffset . ", " . $limiter;


with

if ($sort_row == $q1) $sort_row = "({$q1}+0)";
$order_and_limit_from_sql = "ORDER by " . $sort_row . " " . $order . " " . "LIMIT " . $centeroffset . ", " . $limiter;
if ($sort_row == "({$q1}+0)") $sort_row = $q1;

After these changes header is sorted numerically. It seems to handle 21.3.155 as decimal.

1
2
002
7.9.56
10
21.3.155
31.2.459
100

If you have alphabets in headers they are sorted oddly (by ASCII value I suppose). So there is a drawback to both ways.

malum
21st of January 2005 (Fri), 08:05
Thanks very much.
The parenthesis aren't mine they have been added by EE, none of my numbers have parenthesis around them.
They seem to have been added by having the header conversion set to 'Header (filename)' in the Set Photodata Defaults page

The order that they are put in when they are treated as text is fine (as long as it is consistent) and as I have to edit most of the entries anyway it's not a big deal to resave them all