contao icon indicating copy to clipboard operation
contao copied to clipboard

Correctly check if an error page can be duplicated

Open aschempp opened this issue 2 years ago • 9 comments

Currently, if you have an error_404 (or other error) page in a root page, you cannot duplicate it. That's because the voter checks if such a page already exists in the current root. We need to allow copying if any other root page does not have that type.

aschempp avatar Apr 05 '24 16:04 aschempp

Isn‘t the permission to copy a page independent of whether there is a root page to paste it?

leofeyer avatar Apr 09 '24 09:04 leofeyer

we currently prevent to create multiple error_404 etc. pages inside the same root page, because only one should exist.

aschempp avatar Apr 12 '24 10:04 aschempp

I know. But I should still be able to copy it even if there is no option to paste it. The paste action is what we should prevent, not the copy action.

leofeyer avatar Apr 12 '24 13:04 leofeyer

The paste action is already prevented. But why would I copy if I cannot paste it anywhere?

aschempp avatar Apr 12 '24 13:04 aschempp

Currently, if you have an error_404 (or other error) page in a root page, you cannot duplicate it.

To prevent issues like this one. 😄

leofeyer avatar Apr 12 '24 13:04 leofeyer

?? Thats what this PR fixes?

aschempp avatar Apr 12 '24 13:04 aschempp

You don‘t get the point. The copy operation should always be allowed, independent of hasPageTypeInRoot().

leofeyer avatar Apr 12 '24 14:04 leofeyer

You don‘t get the point. The copy operation should always be allowed, independent of hasPageTypeInRoot().

why? Why would I copy a page if I cannot paste it?

aschempp avatar Apr 16 '24 13:04 aschempp

Because these are two different operations that have nothing to do with each other.

  1. Copy.
  2. Paste.

Yes, that fails if a 404 page exists under every root page. But

  1. Copy.
  2. Delete an existing 404 page.
  3. Paste the duplicated page.

would not fail. However, your logic would prevent it for no reason.

leofeyer avatar Apr 16 '24 13:04 leofeyer