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

Entry condition applied even for single pages #886

Closed
yannkost opened this issue May 8, 2024 · 3 comments
Closed

Entry condition applied even for single pages #886

yannkost opened this issue May 8, 2024 · 3 comments
Labels
bug status: external cause A bug report that was caused by behaviour external to this project bug

Comments

@yannkost
Copy link

yannkost commented May 8, 2024

Bug Description

When adding an entry condition to a neo block (let's say: only if the author belongs to the Administrator group), this condition is verified, even for a section of type single. The single type does not have an author id, so in the InputAsset.php in the following lines will lead to an error and break the cp edit page.

function($blockType) use ($conditionsService, $owner, $ownerClass) {
                    if (isset($blockType->conditions[$ownerClass])) {
                        $condition = $conditionsService->createCondition($blockType->conditions[$ownerClass]);
                        return $condition->matchElement($owner);
                    }

                    return true;
                }

Neo should check if the section type of the entry is single or not, as you can break the control panel with this condition.

Steps to reproduce

  1. Create a neo field and a neo block with a condition on the entry type (author has to be administrator)
  2. Add the field in the layout of an entrytype of a section of type single
  3. The cp can't show the edit page of the single page anymore, as no author_id is present to check for an administrator group.

Expected behaviour

No response

Neo version

4.1.2

Craft CMS version

4.8.9

What is the affected Neo field's propagation method?

No response

Does this issue involve templating, and if so, is eager-loading used?

This is not a templating issue

@ttempleton
Copy link
Contributor

I'm unable to reproduce an error when viewing a single after adding an entry author condition rule to a Neo block type. The block type with the condition applied just doesn't appear as an option on the single, which - given that singles don't have authors, as you've noted - is the correct behaviour.

I'm guessing I'm missing some other detail or misunderstanding something about how to reproduce the error. If possible, could you please provide a video demonstration of the steps you can take to reliably reproduce the error? If not, then could you please post a stack trace?

@ttempleton ttempleton added bug status: unconfirmed A bug report that has not yet been reproduced by the maintainer(s), and more information is required and removed bug status: new labels May 9, 2024
@yannkost
Copy link
Author

Here is a stacktrack screenshot

image

and here the configuration for the field

image

I didn't really had time to make a video.

@ttempleton
Copy link
Contributor

Thanks for posting those screenshots.

I can reproduce this error when applying an author group condition rule to a (non-Neo) field being used on the single's field layout. So Craft's author group condition rule code will need to be fixed, to account for the possibility that $element doesn't have an author.

@ttempleton ttempleton closed this as not planned Won't fix, can't repro, duplicate, stale May 13, 2024
@ttempleton ttempleton added bug status: external cause A bug report that was caused by behaviour external to this project and removed bug status: unconfirmed A bug report that has not yet been reproduced by the maintainer(s), and more information is required labels May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug status: external cause A bug report that was caused by behaviour external to this project bug
Projects
None yet
Development

No branches or pull requests

2 participants