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

A global block in a global block leads to 500 errors #7414

Closed
ghost opened this issue May 8, 2024 · 6 comments · Fixed by #7423
Closed

A global block in a global block leads to 500 errors #7414

ghost opened this issue May 8, 2024 · 6 comments · Fixed by #7423
Assignees
Labels
Bug Error or unexpected behavior of already existing functionality

Comments

@ghost
Copy link

ghost commented May 8, 2024

Q A
Sulu Version 2.6.0
PHP Version 8.3

Actual Behavior

If a global block (e.g. foo) is loaded into another global block (e.g. bar), this results in a 500 error for /admin/config due to a recursion. This was not a problem with includes.

Steps to Reproduce

I have created a small example (with text_block and text_block2):
https://github.com/flogado/sulu-global-blocks/commit/adaab4a398e975de089e9265a019f0f1f74ff26c

Possible Solutions

The recursion seems to happen in the GlobalBlocksTypedFormMetadataVisitor::getGlobalBlockMetadata.

@ghost ghost added the Bug Error or unexpected behavior of already existing functionality label May 8, 2024
@ghost
Copy link
Author

ghost commented May 13, 2024

Do you have a favorite approach? Then I would try to implement it myself. But right now I don't really know how to solve the recursion.

@lubomirfiala
Copy link

I ran into the same problem, but my findings are slightly different: my container was able to handle 2 global blocks inside another global block, but not more.

@alexander-schranz
Copy link
Member

@flogado Thank you for the reproducer this helps. @wachterjohannes will have a look at this, currently not sure but we think recursion happening here:

.

@lubomirfiala if you have another example we should check please let us know.

@alexander-schranz
Copy link
Member

@flogado @lubomirfiala maybe you can give #7423 a try to test if this solve all your issues.

@ghost
Copy link
Author

ghost commented May 14, 2024

The recursion is gone, but now I get the following error in the browser:

Uncaught (in promise) Error: can't resolve reference #/definitions/app-product-category-overview-box from id #

Admin build was successful

rm -rf node_modules package-lock.json
npm i
npm run build

@ghost
Copy link
Author

ghost commented May 14, 2024

I have found the special case that leads to problems. Whenever a regular block comes first, which then contains a block that loads global blocks, this leads to an error.

Example page template:

<?xml version="1.0" ?>
<template
    xmlns="http://schemas.sulu.io/template/template"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://schemas.sulu.io/template/template http://schemas.sulu.io/template/template-1.0.xsd"
>
    <!-- ... -->
    <properties>
        <!-- ... -->
        <block name="foo" default-type="bar">
            <types>
                <type name="bar">
                    <properties>
                        <block name="baz" default-type="app-card">
                            <types>
                                <type ref="app-card" />
                            </types>
                        </block>
                    </properties>
                </type>
            </types>
        </block>
    </properties>
</template>

This results in:

Error: can't resolve reference #/definitions/app-card from id #

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Error or unexpected behavior of already existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants