type array|string is deprecated in _string_to_array

Created on 9 February 2023, over 1 year ago
Updated 5 May 2023, over 1 year ago

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

๐Ÿ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

๐Ÿ‡ซ๐Ÿ‡ฎFinland Anaconda777

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Anaconda777
  • Status changed to Closed: cannot reproduce over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States AltaGrade

    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

  • Status changed to Active over 1 year ago
  • 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)
  • Status changed to Needs review over 1 year ago
  • 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.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia keshav.k

    keshav.k โ†’ made their first commit to this issueโ€™s fork.

  • @keshavk opened merge request.
  • Status changed to RTBC over 1 year ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany tobiberlin Berlin, Germany

    I can confirm that the patch solves this issue

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Anybody Porta Westfalica

    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!

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 8
    last update over 1 year ago
    Unable to generate test groups
  • Status changed to Fixed over 1 year ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Anybody Porta Westfalica
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024