Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Sorting problem in parent view (sorting mode 4) #8292

Closed
qzminski opened this issue Mar 29, 2016 · 4 comments
Closed

Sorting problem in parent view (sorting mode 4) #8292

qzminski opened this issue Mar 29, 2016 · 4 comments
Assignees
Labels
Milestone

Comments

@qzminski
Copy link
Member

Tested on Contao 3.5.9.

Problem 1

There is a sorting problem in the parent view (sorting mode 4) when you get into that view via Save and edit button. It works normally when you enter the page via edit button (yellow pencil icon) in the parent view.

The issue is reproducable in the official Contao demo:

  1. Go to the Events, edit the calendar events.
  2. Create a new event and click the Save and edit button.
  3. Create two new content elements (type does not matter).
  4. Try to change the sorting of content elements - will not work.

Problem 2

On our system there was also a problem with automatic change of pid of content element with ID of the current parent ID. Example:

We have created a calendar event with ID 30 and clicked the Save and edit button. Then we created two content elements. After changing the sorting via drag'n'drop and after refreshing the page, it occurred that Contao behind scenes found tl_content.id=30 and set its tl_content.pid to 30 (ID of calendar event)!

I am pretty sure this would happen on Contao official demo as well but I can't reproduce it now, probably because I can't pair the newly created event ID with the content element that has the same ID.

Hints

I am almost sure that it is related to the URL parameters. If we compare the URL of in theory the same page, in fact we get two different param sets:

URL achieved by clicking the Save and edit button:

contao/main.php?do=calendar&table=tl_content&id=9&mode=2&pid=3

URL achieved by clicking the edit button in parent view:

contao/main.php?do=calendar&table=tl_content&id=9

They are clearly not the same and the major difference is the pid parameter in the first one. That could be the cause of all evil.

I also think the problem may lay somewhere here, at least at some point because it takes the current request (which has that potentially wrong pid parameter):

https://github.com/contao/core/blob/master/assets/contao/js/core-uncompressed.js#L1376-L1393

@Toflar
Copy link
Member

Toflar commented Apr 4, 2016

I can confirm the issue. This is a nasty one! :(

@leofeyer leofeyer added this to the 3.5.13 milestone Apr 27, 2016
@leofeyer leofeyer modified the milestones: 3.5.13, 3.5.14 Jun 13, 2016
@leofeyer
Copy link
Member

leofeyer commented Jun 16, 2016

The following change should fix the issue:

diff --git a/system/modules/core/drivers/DC_Table.php b/system/modules/core/drivers/DC_Table.php
index 5e1e3c6..d38c1b5 100644
--- a/system/modules/core/drivers/DC_Table.php
+++ b/system/modules/core/drivers/DC_Table.php
@@ -2113,7 +2113,7 @@ class DC_Table extends \DataContainer implements \listable, \editable
                \System::setCookie('BE_PAGE_OFFSET', 0, 0);

                $strUrl = $this->addToUrl($GLOBALS['TL_DCA'][$this->strTable]['list']['operations']['edit']['href'], false);
-               $strUrl = preg_replace('/(&)?(s2e|act)=[^&]*/i', '', $strUrl);
+               $strUrl = preg_replace('/&(amp;)?(s2e|act|mode|pid)=[^&]*/i', '', $strUrl);

                $this->redirect($strUrl);
            }

@qzminski Can you please confirm?

@Toflar
Copy link
Member

Toflar commented Jun 16, 2016

I can confirm the bugfix fixes both, problems 1 and 2!

@leofeyer
Copy link
Member

Fixed in ef87e7b.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants