Jump to content

Manually sorted images revert to previous order on save


Recommended Posts

After manually re-ordering images in the back end, when the page is saved, the images revert to their original order:

  • Starting order: A B C
  • Manually re-order: A C B
  • Save, and the order reverts to: A B C

This does not happen on all pages. Notable, newly created pages don't seem to have the problem (though it's possibly being newly created isn't the issue).

Various other things have changed over time with the image field in (the biggest one being introducing custom fields), so it is possible that reason some pages are affected and not others is connected to when the page was created – but this is a total guess.

The issue may have started on updating to PW 3.0.184, but I'm not sure about this.

I'm not sure where to go next with this. Does anyone have suggestions for causes of the problem or ways to go about debugging?

Link to comment
Share on other sites

@BillH You may have a look into the DBs table of an image field and check what numbers are set in the column "sort" before and after you opened, changed and saved or reopened a special page. If you have no DB viewer app at hand, you also can use a little debug script (cli script) to check this.

Example script for CLI access, given the images field is named "images" and the page id of one problematic page is "1234":

<?php namespace ProcessWire;

$tablename = 'field_images';
$pages_id = 1234;

echo '<pre>';

    $query = "SELECT data, sort FROM {$tablename} WHERE pages_id={$pages_id}";
    $pDOStatement = $database->query($query);

    foreach($pDOStatement as $row) {
        echo "\n{$row['sort']} :: {$row['data']}";

echo "\n\nReady!";

You may check if all image entries have a value in the column "sort", if it is a valid value, starting from 0 and is up counting, if it changes and when, etc. This may help a bit on coming closer to the issue.
Do the older pages use the same images field and also the same template then the newer pages? If not, are there different per template settings for the images field? ...

  • Like 1
Link to comment
Share on other sites

Many thanks @horst, that's really helpful. I wasn't aware of the "sort" column.

All pages use the same image field. The pages use three different templates, but the problem occurs in the same way with all three templates, and the field settings are the same on each template.

I'll investigate following your suggestions and report back.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

This is a slow bit of reporting back, but it might be useful for anyone who comes across the same issue.

In brief, the problem has gone away, but I don't know why.

All I did was follow @horst's advice and look at the "sort" column in the database. I watched the column changing and made a couple of manual changes to discover how it worked... And then found that the bug had gone way - and for all pages where it had occurred. Several users experienced the bug, but they have now been using the system for several weeks without it recurring, so it seems to be fixed.

I don't like leaving an issue without finding out the root cause, but I haven't been able to work anything out. If sombody has the same issue, try what I did and keep your fingers crossed!




  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...