Problem/Motivation

Hi,
I am getting this:

Deprecated function: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in _string_to_array()
Using PHP 8.1

modules/contrib/protected_forms/protected_forms.module

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#4 protected-forms-3340551-deprecated-string.patch831 bytesj.
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

Anaconda777 created an issue. See original summary.

altagrade’s picture

Status: Active » Closed (cannot reproduce)

All issues must be filed against 2.0.x-dev. Feel free to re-open this ticket if it persists on 2.0.x-dev

j.’s picture

Version: 2.0.2 » 2.0.x-dev
Status: Closed (cannot reproduce) » Active

I am getting the error on 2.0.x-dev, 9.5, php 8.1. It happens after i logout/login.

Deprecated function: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in _string_to_array() (line 259 of modules/contrib/protected_forms/protected_forms.module).
_string_to_array(NULL) (Line: 81)
_protected_forms_validate(Array, Object)
call_user_func_array('_protected_forms_validate', Array) (Line: 82)
Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object) (Line: 275)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'user_login_form') (Line: 118)
Drupal\Core\Form\FormValidator->validateForm('user_login_form', Array, Object) (Line: 591)
Drupal\Core\Form\FormBuilder->processForm('user_login_form', Array, Object) (Line: 323)
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: 580)
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: 46)
Drupal\redirect_after_login\RedirectMiddleware->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: 50)
Drupal\ban\BanMiddleware->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: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
j.’s picture

Category: Support request » Bug report
Status: Active » Needs review
StatusFileSize
new831 bytes

I think i found our problem. We aren't using any allowed patterns. So in our case $allowed_patterns is passing along an empty string, which then triggers the error in _string_to_array. This patch checks if $allowed_patterns has content before proceding.

keshav.k made their first commit to this issue’s fork.

keshavv’s picture

Status: Needs review » Reviewed & tested by the community
tobiberlin’s picture

I can confirm that the patch solves this issue

anybody’s picture

The fix is strange, as the error in the issue summary is about

Passing null to parameter #3 ($subject)

which is not affected here, but NULL-checked some lines before already.

This fix definitely doesn't make things worse, so let's merge it!

  • Anybody committed 70e9a76e on 2.0.x authored by keshav.k
    Issue #3340551: type array|string is deprecated in _string_to_array
    
anybody’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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