Bug #91223

Content element sorting is broken in the page module

Added by Michell Kalb 2 months ago. Updated 4 days ago.

Status:
Under Review
Priority:
Must have
Assignee:
Category:
Backend User Interface
Target version:
Start date:
2020-04-28
Due date:
% Done:

0%

TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
easy
Is Regression:
Yes
Sprint Focus:

Description

Page module in the backend doesent respect the order/sorting of the content elements if a backend layout with multiple rows is used.
Changing the order via drag and drop is working as long as i dont reload. Once i reload i see the old ordering by uid in the backend but its working in frontend. This doesent happens without a custom backend layout.

Steps to reproduce:
  1. Install a fresh version of TYPO3 10.4.0
  2. Create some content elements in the backend (ordering is working now)
  3. Create a backend layout with 2 rows (see below)
  4. Try to rearrange the content elements
  5. Reload the frame/click on page and you see the old ordering by creation date/uid

Here is the backend layout i used:

mod.web_layout.BackendLayouts {
  exampleKey {
    title = Example
    icon = EXT:example_extension/Resources/Public/Images/BackendLayouts/default.gif
    config {
      backend_layout {
        colCount = 1
        rowCount = 2
        rows {
          1 {
            columns {
              1 {
                name = 0x0
                colPos = 1
              }
            }
          }
          2 {
            columns {
              1 {
                name = 0x1
                colPos = 0
              }
            }
          }
        }
      }
    }
  }
}

bug.png View (121 KB) Martin Weymayer, 2020-05-11 09:33


Related issues

Related to TYPO3 Core - Bug #90235: Page module allows to break content of subpages Closed 2020-01-28

History

#1 Updated by Georg Ringer 2 months ago

  • Status changed from New to Needs Feedback

Thanks for your report! Which type of page module are you using? You can check that in Install Tool > Settings > Feature toggles > Fluid based page module > Is this enabled or disabled?

If it is enabled, can you please check if it works if it is disabled which uses then the "classic page module."

#2 Updated by Michell Kalb 2 months ago

Georg Ringer wrote:

Thanks for your report! Which type of page module are you using? You can check that in Install Tool > Settings > Feature toggles > Fluid based page module > Is this enabled or disabled?

If it is enabled, can you please check if it works if it is disabled which uses then the "classic page module."

It appears in both modes. Changing to classic doesent fix it but currently im using the new one.
Looks like this issue disappears at a certain amount of CEs. With one CE in col 1 and two CEs in col 0 the sorting isnt working but now i have about seven CEs in col 0 and its working...strange.

#3 Updated by Sven Wiener 2 months ago

Got the same Issue at TYPO3 10.4.1 in both modes, even if I use only one column.

#4 Updated by Oliver Pfaff 2 months ago

TYPO3: 10.4.1
Fluid based page module
PHP 7.3.12

I got the same bug. The output on the frontend side differs from that what we see in the module, but the frontend ordering respects the ordering saved in the DB. After the bug occurs, the ordering can't be changed anymore through the module and no change will be applied in the db .

#5 Updated by Alessandro Schmitz 2 months ago

Same issue for me.

Probably another useful information:
Creating a menu through a MenuProcessor for all content elements of the current page (e.g. for one pagers and so), the order in the menu differs from the order in the content.

Example:

Menu:
News - About us - Contact

Content:
1. Contact
2. News
3. About us

#6 Updated by Sven Wiener 2 months ago

In the case of Contentelements:
Even if the ordering is changed via drag and drop, the sorting in the db is changed correctly. Just the output in the BE-view is wrong. I got two reloads in that view. first the output is correct and after a second reload it is sorted back by uid.

#7 Updated by Martin Weymayer about 2 months ago

  • Priority changed from Should have to Must have

I have same problem in 10.4.1. Sorting in list view in backend is correct, also frontend rendering has correct sorting. only sorting in page view in backend is wrong. Strange is, that in subpages sorting seems working correct, only on root page sorting is wrong.

#8 Updated by Martin Weymayer about 2 months ago

Hm ... this is realy strange ... I now changed some deleted elements in database (set visible and changed page id) and suddenly sorting is correct. I had same behaviour yesterday and after some other changes sorting was broken again???

#9 Updated by Martin Weymayer about 2 months ago

realy, realy strange. I found out, that certain content elements break sorting. On screenshot - if I change marked element form page id 99 to 1, sorting is broken on page with id 1 in backend. change it to any other pid, sorting on page with id 1 in backend is correct. So I think the bug is concerning number of elements or/and number of sorting of certain elements?

I tried this also on other content elements. f.e. content element with id 9 -> change from pid 3 to pid 1 sorting is broken. change it back from 1 to 3 sorting is correct.

number of sorting in db seems also a little bit strange. 1,2,4,8 ... - normaly the numbers are higher, aren't they?

#10 Updated by Martin Weymayer about 2 months ago

... it seems to be some combination with the number of content elements of page. In my case, if I have 16 or more content elments active, sorting is broken. 15 elements -> sorting is ok. But I do not know what it is depending. Because yesterday when see bug first time, there where only about 8 elements active and sorting was broken also.

#11 Updated by Martin Weymayer about 2 months ago

I am not sure, if my hack is fine, but adding sorting in query builder seems to fix my problem. In file typo3/sysext/backend/Classes/View/BackendLayout/ContentFetcher.php I added in line 210 ->orderBy('sorting');

..
$queryBuilder
            ->select(...$fields)
            ->from('tt_content')
            ->orderBy('sorting');

        $queryBuilder->andWhere(
...

#12 Updated by Peter Bünemann about 2 months ago

I have an empty, new 10.4.1 installation. Sorting does not work in the page module. After adding "orderBy('sorting');" it works. After installation and activation of "gridelements" it does not work again. I created a simple single-column gridelement. All content elements moved into the grid. Sorting works within the grid. All content elements moved out of the grid again. Sorting does not work

#13 Updated by Oliver Kurth about 2 months ago

I have the same Problem!

#14 Updated by Jo Hasenau about 1 month ago

  • Subject changed from Using backend layouts breaks content element sorting in backend to Content element sorting is broken in the page module
  • Assignee set to Jo Hasenau
  • Target version set to next-patchlevel
  • PHP Version deleted (7.3)
  • Complexity set to easy
  • Is Regression set to Yes

You don't need to assign a backend layout at all, since the bug already appears with a completely fresh install.
Using D&D on a single page containing 3 default header elements in the normal column of the default layout you will get the correct sorting values in the DB but those are ignored by the page module view as soon as you reload.
Frontend works fine, so the bug is related to the page module only.

Happens with both, legacy and fluid based page module.

#15 Updated by Jo Hasenau about 1 month ago

This seems to have been the regression for the legacy PageLayoutView, since the whole $addSorting section has been removed.
Later on the parameter was removed from the method parameters too, but sorting has not been reimplemented yet.

https://review.typo3.org/c/Packages/TYPO3.CMS/+/63063/9/typo3/sysext/backend/Classes/View/PageLayoutView.php#b3032

        if ($addSorting) {
            if ($this->sortField && in_array($this->sortField, $this->makeFieldList($table))) {
                $queryBuilder->orderBy($this->sortField, $this->sortRev ? 'DESC' : 'ASC');
            } else {
                $orderBy = $GLOBALS['TCA'][$table]['ctrl']['sortby'] ?: $GLOBALS['TCA'][$table]['ctrl']['default_sortby'];
                $orderBys = QueryHelper::parseOrderBy((string)$orderBy);
                foreach ($orderBys as $orderBy) {
                    $queryBuilder->addOrderBy($orderBy[0], $orderBy[1]);
                }
            }
        }

Since the ContentFetcher class has been created for the first time after that patch, the sorting part is missing in there too, because it was unknown to the team working on it, that the former $addSorting parameter did not exist anymore.

#16 Updated by Gerrit Code Review about 1 month ago

  • Status changed from Needs Feedback to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/64567

#17 Updated by Gerrit Code Review about 1 month ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/64567

#18 Updated by Gerrit Code Review about 1 month ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/64567

#19 Updated by Jo Hasenau about 1 month ago

  • Related to Bug #90235: Page module allows to break content of subpages added

#20 Updated by Julian Stock about 1 month ago

I don't know if this is only a gridelements related problem which we're using on our pages, but if that's not the case, then I realized this unexpected behaviour in TYPO3 v9.5.17 & 9.5.18, too.

- We're placing a header and a text element inside a gridelement in a workspace environment (not PROD) and check this in the frontend: everything is looking fine.
- Then we're changing the order of the two elements via drag and drop: text first, header second. For a short time everything is looking like expected, then there's the autoreload and after that the ordering is the same as before (header first, text second). But in the frontend is the text first, header second.

Can anyone reproduce that behaviour? When NOT using a workspace, everything is working fine.

Update: The same is happening on TYPO3 v8.7.30 (& gridelements v8.5.2).

#21 Updated by Peter Bünemann 26 days ago

New TYPO3 version 10.4.4 LTS but the same problem. Sorting in the page module not possible. Version 10 is not usable at the moment.

#22 Updated by Felix Holler 11 days ago

The Same for me with TYPO3 10.4.4 together with gridelements version 10 and new_bootstrap_gridelements version 10. Ordering in page module is broken. You can reorder CEs but the visual Feedback is wrong.
The Patch (https://review.typo3.org/c/Packages/TYPO3.CMS/+/64567) is working fine. Thanks to all that worked on this patch!

#23 Updated by Martin Weymayer 5 days ago

Still problems in 10.4.4 with sorting. Gridelements and Mask installed.

#24 Updated by Andre Koller 4 days ago

Same here. Typo3 10.4.4, Mask 5.0.0, Gridelements 10.0.0

Also available in: Atom PDF