Bug #87677

Pasting content element to page does not work

Added by Philipp Seiler 8 days ago. Updated 1 day ago.

Status:
Resolved
Priority:
Must have
Assignee:
-
Category:
-
Target version:
-
Start date:
2019-02-08
Due date:
% Done:

0%

TYPO3 Version:
9
PHP Version:
Tags:
gridelements,paste,clipboard,copy,datahander,controller
Complexity:
Is Regression:
Sprint Focus:

Description

  1. Copy any content element like textmedia from page A.
  2. Go to page B - currently empty.
  3. Paste record in. Works.
  4. Copy another content element form page A.
  5. Go to page B.
  6. Paste record in after previously pasted record. Works.
  7. Copy another content element form page A.
  8. Go to page B.
  9. Paste record in on top ("Paste into this column"). Error.
1: Attempt to insert record "tt_content:123" on a page (Page Title) that can't store record type.

1: Attempt to insert record on page '[root-level]' (0) where this table, tt_content, is not allowed

Problem, it seems, lies in incorrect request parameters when calling the SimpleDataHandlerController.

Request parameters of a paste operation that works:

Array
(
    [route] => /ajax/record/process
    [token] => abc
    [cmd] => Array
        (
            [tt_content] => Array
                (
                    [123] => Array
                        (
                            [copy] => Array
                                (
                                    [action] => paste
                                    [target] => 3
                                    [update] => Array
                                        (
                                            [colPos] => 0
                                            [tx_gridelements_container] => NaN
                                            [tx_gridelements_columns] => 0
                                            [sys_language_uid] => 0
                                        )

                                )

                        )

                )

        )

)

Note that [target] is an integer referring to the page being copied to.

Request parameters of a paste operation that fails:

Array
(
    [route] => /ajax/record/process
    [token] => qwe
    [cmd] => Array
        (
            [tt_content] => Array
                (
                    [123] => Array
                        (
                            [copy] => Array
                                (
                                    [action] => paste
                                    [target] => Page Title
                                    [update] => Array
                                        (
                                            [colPos] => 0
                                            [tx_gridelements_container] => NaN
                                            [tx_gridelements_columns] => 0
                                            [sys_language_uid] => 0
                                        )

                                )

                        )

                )

        )

)

Note that [target] now is the page title (?!).
This leads to $this->tce->start($this->data, $this->cmd); in SimpleDataHandlerController being initialized with an invalid pageId value, and therefore failing to create correct cmd parameters. initializeClipboard will then also not be called.

I tried to debug this behaviour for about an hour, but I cannot for the love of anything find out, where this originates from.
This error also happens in some combinations with copying to different language columns.

History

#1 Updated by Philipp Seiler 8 days ago

  • Subject changed from Copying content element in top of page does not work to Pasting content element to page does not work

#2 Updated by Philipp Seiler 8 days ago

  • Description updated (diff)

#3 Updated by Philipp Seiler 5 days ago

If the pages only exist in root-language copying seems to work OK.
When the pages are translated, the error described above occurs.

#4 Updated by Philipp Seiler 5 days ago

Same thing happens when moving an element to the top of the page:

Moving element to somewhere but the top - works:

route    /ajax/record/process
token    123
cmd[tt_content][146][move]    -147
data[tt_content][146][colPos]    0
data[tt_content][146][tx_gridelements_container]    NaN
data[tt_content][146][tx_gridelements_columns]    0
data[tt_content][146][sys_language_uid]    0

Moving element to the top - fails:

route    /ajax/record/process
token    123
cmd[tt_content][146][move]    Kopier-Test B
data[tt_content][146][colPos]    0
data[tt_content][146][tx_gridelements_container]    NaN
data[tt_content][146][tx_gridelements_columns]    0
data[tt_content][146][sys_language_uid]    0

#5 Updated by Philipp Seiler 5 days ago

Oh boy, I think I got it. It has probably nothing to do with TYPO3, but with Gridelements.

In gridelements\Resources\Public\JavaScript\GridElementsDragDrop.js a function called DragDrop.default.onDrop exists. This function is, as it seems, called on all operations done with content elements. The method also calls the DataHandler.process AJAX-Call with determined parameters. To do this, the Gridelements-JS tries to resolve the pageUid from some DOM-Elements on the page. However, those selects are either wrong, or do not work anymore with TYPO3 v9.

I implemented a fix in the Gridelements JavaScript. No idea however, if this is realiable.
In gridelements\Resources\Public\JavaScript\GridElementsDragDrop.js around line #206:

if (typeof targetFound === 'undefined') {
    // the actual page is needed

    // Wrong! data-page holds the page title, not the UID!
    // targetPid = $('[data-page]').first().data('page');

    targetPid = $droppableElement.closest(DragDrop.default.contentIdentifier).data('page');
} else {
    // the negative value of the content element after where it should be moved
    targetPid = 0 - parseInt(targetFound);
}

As described in the fix above, the DOM Element $('[data-page]').first().data('page') holds the pageTitle, not the UID. Maybe this is a TYPO3 Bug, where this should indeed hold the pageUid, but it does not?

#6 Updated by Philipp Seiler 5 days ago

  • Tags changed from paste,clipboard,copy,datahander,controller to gridelements,paste,clipboard,copy,datahander,controller

#7 Updated by Wolfgang Klinger 1 day ago

  • Category deleted (DataHandler aka TCEmain)
  • Status changed from New to Resolved

Not a core bug.
The extension bug has already been fixed: https://gitlab.com/coderscare/gridelements/commit/448df6a4eb34f2bdd541a2c22fb0957de7e2d862

I close this issue as resolved.

Also available in: Atom PDF