[PHP 8.1] Deprecated function: mb_strlen(): Passing null to parameter #1

Created on 29 November 2022, about 2 years ago
Updated 25 April 2023, over 1 year ago

Problem/Motivation

I use this module in conjunction with content_access module. After upgrade to PHP 8.1 debug log reported as below:

Deprecated function: mb_strlen(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Core\Form\FormValidator->performRequiredValidation() (line 336 of core/lib/Drupal/Core/Form/FormValidator.php).
Drupal\Core\Form\FormValidator->performRequiredValidation(Array, Object) (Line: 246)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object) (Line: 238)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object) (Line: 238)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object) (Line: 238)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'content_access_page') (Line: 118)
Drupal\Core\Form\FormValidator->validateForm('content_access_page', Array, Object) (Line: 588)
Drupal\Core\Form\FormBuilder->processForm('content_access_page', 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: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 67)
Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->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: 709)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

At first I thought the issue is related to content_access module itself, however after a deep dive into debugging I have found out it's actually a ACL fault. In acl.admin.inc, line 134 you can find a value may be set to NULL ( $form['add']['#value'] = NULL; ), which is eventually getting passed to a form element and is causing a trouble. Attaching a small patch to fix it.

Steps to reproduce

1. Install content_access and acl module (and make sure your PHP is 8.1)
2. Go to /admin/structure/types/manage/{your_content_type}/access
3. Put a tick into Enable per content node access control settings checkbox and save settings
4. Go to node/{your_node_id}/access (node should belong to CT modified above)
5. In Grant view access section select any user and press Add User
6. After user is added you should see error reported above

Proposed resolution

The patch is attached.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine oleg chemerys

Live updates comments and jobs are added and updated live.
  • PHP 8.1

    The issue particularly affects sites running on PHP version 8.1.0 or later.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024