Problem/Motivation

After creating a new content type and adding that content type to twig templates, the page completely crashed for logged out users, but did not give any useful information. Instead the screen displayed:
Error: Maximum function nesting level of 512 reached, aborting! in Drupal/Core/Render/Renderer.php

The problem was discovered to be that the new content type was not added to the anonymous user role permissions.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3155953

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

ethomas08 created an issue. See original summary.

ethomas08’s picture

Status: Active » Needs review
StatusFileSize
new831 bytes

Here is my patch for the reminder message after a user adds a new content type.

ethomas08’s picture

StatusFileSize
new831 bytes

Patch file without the word patch at the end of it

cilefen’s picture

Version: 8.9.x-dev » 9.1.x-dev

@ethomas08

Thank you for this. Translatable string changes are always pushed to minor releases, so I've moved this to 9.1.x.

In my opinion, it would be preferable to fix the root problem:

After creating a new content type and adding that content type to twig templates, the page completely crashed for logged out users...

Drupal could perhaps handle that better. We need a major-priority issue for that. Could you please report that with steps to reproduce, if no such issue exists?

Thank you!
-Chris

ethomas08’s picture

Hi Chris, thank you so much for your very speedy response time! I was not able to get exact steps to reproduce this error. My team says it is a special case situation, and it would not likely impact many other users.

ethomas08’s picture

Uploading patch that contains a link to the permissions page, as requested by team members.

ethomas08’s picture

Re-rolled patch for 9.1.x branch

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

abhijith s’s picture

StatusFileSize
new40.07 KB

Applied the patch #7 on 9.2.x and it works fine .But found CS error.

 233 | ERROR | [x] Array indentation error, expected 8 spaces but found 10
 234 | ERROR | [x] Array indentation error, expected 8 spaces but found 10
 235 | ERROR | [x] Array closing indentation error, expected 6 spaces but found 8

After patch:
after

abhijith s’s picture

StatusFileSize
new1.21 KB

Fixed the CS error in patch #7.Please check it

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs tests, +Novice, +Needs screenshots

This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

YES!! This feature would be absolutely amazing to have

Patch #10 still applies to D10

Tagging for before/after screenshots to be added to the issue summary (would be a good time to update to regular templates)

This will need test coverage but we should be able to extend existing tests already for when a content type is created, should be a good novice task.

joaopauloc.dev’s picture

Adding unit tests.

joaopauloc.dev’s picture

Adding full patch

joaopauloc.dev’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
smustgrave’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs screenshots
StatusFileSize
new32.55 KB
new46.76 KB

Went ahead and added screenshots.

Testing locally on Drupal 10 creating a new content type and seeing the link.

Good job with the test!

quietone’s picture

Assigned: ethomas08 » Unassigned
Issue summary: View changes
Status: Reviewed & tested by the community » Needs work
Issue tags: +Usability, +Needs usability review

Reading the Issue Summary I see that the proposed resolution is not following the Drupal user interface text standard, specifically the use of 'please'.

This is changing the UI so needs the usability tag, per the Usability gate. I am adding the tag. Having said I think the text should also be reviewed, adding tag for a usability review.

The issue summary states that this solution is 'for the time-being'. What is the long term solution?

Thank you for having up to date screen shots available in the Issue Summary! That has saved me searching for them.

    I looked at the patch as well.

  1. +++ b/core/modules/node/src/NodeTypeForm.php
    @@ -8,6 +8,7 @@
    +use Drupal\Core\Url;
    

    This should be sorted.

  2. +++ b/core/modules/node/tests/src/Functional/NodeTypeTest.php
    @@ -88,8 +88,11 @@ public function testNodeTypeCreation() {
    +    $this->assertTrue((bool) $type_exists, 'The new content type has been created in the database.');
    

    Since this is being changed, the message can be removed.

  3. +++ b/core/modules/node/src/NodeTypeForm.php
    @@ -228,7 +229,10 @@ public function save(array $form, FormStateInterface $form_state) {
    +      $this->messenger()->addStatus($this->t('The content type %name has been added. Please remember to check <a href="@permissions_url">user permissions</a> for this content type', [
    

    s/@permission/:permission/

    That is, according to protected static function FormattableMarkup::placeholderFormat

Finally, un-assigning because that person hasn't worked on this in 3 years.

sourabhjain’s picture

Assigned: Unassigned » sourabhjain

I am working on #20.

sourabhjain’s picture

Assigned: sourabhjain » Unassigned
Status: Needs work » Needs review

I have fixed the issue mentioned in #20 and created the MR for that. Please review.

smustgrave’s picture

Status: Needs review » Needs work
joaopauloc.dev’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

From comment #20

The issue summary states that this solution is 'for the time-being'. What is the long term solution?

This needs to be addressed for the committers

joaopauloc.dev’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs issue summary update

Updating issue summary, I couldn't reproduce the crash mentioned, this issue is old and Drupal probably handle this in a best way than when the issue was created.

lauriii’s picture

Issue tags: +Field UX
skt-001’s picture

applying the patch #17 works as remainder message.

skt-001’s picture

StatusFileSize
new792.93 KB
new827.4 KB
bnjmnm’s picture

I think I'm missing something here. If I create a new content type, then create content of that type without making any permission changes, an anonymous user can see that content just fine. There's a 'View published content' permission that if disabled would restrict anonymous access to content overall - there's no Content-Type-Specific setting that requires changing. Either the site lets anonymous users see published content or it doesn't. Perhaps the user that reported this was using the Node View Permissions module?

The permissions system is designed to gracefully block access to something vs. dumping someone into a recursion vortex, so that's a bit confusing too.

Is there a setting/use case I'm missing. I like better info, but I'm concerned this alerting users to a situation that they don't have to attend to.

bnjmnm’s picture

Status: Needs review » Postponed (maintainer needs more info)
smustgrave’s picture

Think it's just a helper comment. To remind the developer to set up their permissions. As a developer is building with admin role they may forget to setup the content type for the other roles.

lauriii’s picture

Title: Add reminder message when user creates new content type to enable node permissions » Error when viewing page as anonymous user with missing permissions
Category: Feature request » Bug report
Issue summary: View changes
Issue tags: -Novice, -Usability, -Needs usability review, -Field UX

To keep our options open, let's reframe this issue to focus on the problem. I agree that one potential solution is to add a reminder message for users to configure permissions properly, but there could be other solutions to the problem.

To evaluate the alternative solutions, let's take a step back and ask why we need to add this reminder message. It appears that an error occurred because the author did not grant anonymous users access to the content type. It sounds totally reasonable to not configure permissions for a content type after it has been created. This certainly shouldn't result in PHP errors, so we need to investigate further and come up with a solution to that. This way I believe we wouldn't need the message in the first place.

I am keeping this issue as postponed until we have reproducible steps for the bug.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

ethomas08’s picture

Hi everyone, so interesting to see all the comments after I originally created this issue 3 years ago!

I cannot remember the specifics, since I no longer have access to the project. I believe bnjmnm is correct in that there was most likely a contrib module enabled to handle permissions on a more granular level.

It is very possible that this is no longer a bug since Drupal core has progressed from Drupal 8 (at the time of this issue's creation) to Drupal 11.

acbramley’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Closing as there is nothing in core that would cause this bug after creating a new content type.

Feel free to reopen with clear steps to reproduce, or open a new feature request for the addition of the permissions message.