Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Prevent error when be:uri.editRecord is used in preview template #549

Merged
merged 1 commit into from
May 10, 2023

Conversation

nitori
Copy link
Contributor

@nitori nitori commented May 9, 2023

Without the request on the rendering context, the uri.editRecord and link.editRecord ViewHelpers of the backend module are unable to automatically generate a returnUrl.

In the case of uri.editRecord we get an exception in the page module, and with the link.editRecord we'll end up on a blank page, when trying to use the close button to return to the previous page.


Not sure if there is a better way to get the TYPO3_REQUEST than through $GLOBALS. Maybe injection?

Also not sure if that perhaps is more of a TYPO3 core bug.

Anyway, I encountered this, because I like to add direct links to nested Content Elements if present right in the Page Module.

An example preview template taken from an Accordion Element:

<f:if condition="{data.tx_mask_accordion}">
    <f:for each="{data.tx_mask_accordion}" as="accordion" iteration="i">
        <div class="well well-sm">
            <div>
                <strong>{accordion.tx_mask_header}</strong>
            </div>
            <f:if condition="{accordion.tx_mask_content}">
                <f:for each="{accordion.tx_mask_content}" as="ce">
                    <f:alias map="{editLink: '{be:uri.editRecord(uid: ce.uid, table: \'tt_content\')}'}">
                        <div>
                            <span title="id={ce.uid}" data-toggle="tooltip" data-placement="top">
                                <core:iconForRecord row="{ce}" table="tt_content"/>
                            </span>
                            <a href="{editLink}" data-toggle="tooltip" data-placement="top" title="id={ce.uid}">
                                <core:icon identifier="actions-open"/>
                            </a>
                            <a href="{editLink}">
                                <f:render section="Label" arguments="{ce: ce}"/>
                            </a>
                        </div>
                    </f:alias>
                </f:for>
            </f:if>
        </div>
    </f:for>
</f:if>

If it wasn't the uri-ViewHelper but the link one instead, I'd probably never have noticed this error.

…late

Without the request on the rendering context, the uri.editRecord and link.editRecord ViewHelpers of the backend module are unable to automatically generate a returnUrl.

In the case of uri.editRecord we get an exception in the page module, and with the link.editRecord we'll end up on a blank page, when trying to use the close button to return to the previous page.
@nitori
Copy link
Contributor Author

nitori commented May 9, 2023

Also, it seems to only appear in TYPO3 12.

And I haven't tested this specific issue on TYPO3 11
It seems to work just fine.

@nhovratov nhovratov self-requested a review May 10, 2023 10:56
@nhovratov
Copy link
Collaborator

Unfortunately, there is no other way. The Event doesn't provide the request object, so using the global is required.
This patch: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75779
removed the request (with attached extbase context) completely.

@nhovratov nhovratov merged commit 2ea97c7 into Gernott:main May 10, 2023
nhovratov pushed a commit that referenced this pull request May 10, 2023
…late (#549)

Without the request on the rendering context, the uri.editRecord and link.editRecord ViewHelpers of the backend module are unable to automatically generate a returnUrl.

In the case of uri.editRecord we get an exception in the page module, and with the link.editRecord we'll end up on a blank page, when trying to use the close button to return to the previous page.

Co-authored-by: Lars Peter Søndergaard <l.soendergaard@lichtflut-medien.de>
(cherry picked from commit 2ea97c7)
@nhovratov
Copy link
Collaborator

Thanks Lars, I will wait until next week for the next release. Maybe something else will pop up.

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

Successfully merging this pull request may close these issues.

None yet

3 participants