Due https://www.drupal.org/project/cookieconsent/issues/2910802 visiting the Form Settings returns a warning if no cookie_policy value has been provided (i.e. the first time you visit the form settings).
Warning: array_flip(): Can only flip STRING and INTEGER values! in Drupal\Core\Entity\EntityStorageBase->loadMultiple() (line 227 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).
Drupal\Core\Entity\EntityStorageBase->loadMultiple(Array) (Line: 212)
Drupal\Core\Entity\EntityStorageBase->load(NULL) (Line: 85)
entity_load('node', NULL) (Line: 126)
Drupal\cookieconsent\Form\SettingsForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 514)
Drupal\Core\Form\FormBuilder->retrieveForm('cookieconsent_settings_form', Object) (Line: 271)
Drupal\Core\Form\FormBuilder->buildForm('cookieconsent_settings_form', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
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}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Conditionally check if $config->get('cookie_policy') exists before calling entity_load(),
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | php-warning-settingsform-policy-not-set-2930734-7.patch | 2.07 KB | villette |
| #6 | cookie_compliance_drupal_8_4.patch | 899 bytes | noita |
| #2 | 2930734-2.patch | 528 bytes | gambry |
Comments
Comment #2
gambryComment #3
gambryComment #4
gambryComment #5
opiSimple onleline, tested and approved, thanks !
Comment #6
noita commentedEntity load is now deprecated and then if you pass a patch it's better to change call function. I have change line to be ok with drupal compliance.
Hope than can help.
PS: sry for my english
Comment #7
villette commentedThe entity_load() function is deprecated indeed, but in this case, the best way to use the entity_type.manager service (entity.manager is also deprecated now) is to inject it into the block plugin as explained here.
Comment #8
gambry$cookie_policy_nid is almost useless. Why don't just check
if ($config->get('cookie_policy'))?$cookie_policy_nid is almost useless. Why don't just check
if ($config->get('cookie_policy'))?I know it's going to be a long line, but can't we simplify the code and just use the ternary operator?
Comment #9
nitebreedThank for the patch, I updated it with the changes mentioned in #8