Problem/Motivation

On new installs when you enter on settings page it's expecting the config "bypass_role" that hasn't been created and a warning is showed:

Warning: Invalid argument supplied for foreach() in Drupal\Core\Render\Element\Checkboxes::valueCallback() (line 100 of core/lib/Drupal/Core/Render/Element/Checkboxes.php).
Drupal\Core\Render\Element\Checkboxes::valueCallback(Array, , Object)
call_user_func_array(Array, Array) (Line: 1277)
Drupal\Core\Form\FormBuilder->handleInputElement('pages_restriction_admin_settings', Array, Object) (Line: 1000)
Drupal\Core\Form\FormBuilder->doBuildForm('pages_restriction_admin_settings', Array, Object) (Line: 1070)
Drupal\Core\Form\FormBuilder->doBuildForm('pages_restriction_admin_settings', Array, Object) (Line: 1070)
Drupal\Core\Form\FormBuilder->doBuildForm('pages_restriction_admin_settings', Array, Object) (Line: 574)
Drupal\Core\Form\FormBuilder->processForm('pages_restriction_admin_settings', Array, Object) (Line: 320)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

Install module and access the settings page.

Proposed resolution

It can be resolved by:
1- validating is the config exists before use the config or
2- create the config empty for new installs
3- Or both solutions...

I created a patch following the second option.

CommentFileSizeAuthor
#2 3259416-2.patch292 byteswesleyl

Comments

wesleyl created an issue. See original summary.

wesleyl’s picture

Status: Active » Needs review
StatusFileSize
new292 bytes

Here is the patch

victoria-marina’s picture

Assigned: Unassigned » victoria-marina

I'll review this.

victoria-marina’s picture

Assigned: victoria-marina » Unassigned
Status: Needs review » Reviewed & tested by the community

I've installed module, reproduced the issue, applied the patch and tested it again. Everything is ok!

renatog’s picture

Version: 8.x-1.4 » 8.x-1.x-dev
Priority: Minor » Normal

It totally makes sense. Thank you so much @wesleyl for your solution and @victoria-marina for your review, Great job!

  • RenatoG committed 8077778 on 8.x-1.x authored by wesleyl
    Issue #3259416 by wesleyl, victoria-marina, RenatoG: On new installs it'...
renatog’s picture

Status: Reviewed & tested by the community » Fixed

Moved to the dev branch.

Thank you so much

renatog’s picture

I've created a new release with this: https://www.drupal.org/project/pages_restriction/releases/8.x-1.5

To use in our projects we can run:

$ composer require 'drupal/pages_restriction:^1.5'

Thanks a lot

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.