Deprecated function: preg_match() in ColorSystemBrandingBlockAlter.php

Created on 13 February 2024, 4 months ago
Updated 20 April 2024, 2 months ago
Deprecated function: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in Drupal\color\ColorSystemBrandingBlockAlter::preRender() (line 27 of /SITE/PATH/web/modules/contrib/color/src/ColorSystemBrandingBlockAlter.php) #0 /SITE/PATH/web/core/includes/bootstrap.inc(164): _drupal_error_handler_real()
๐Ÿ› Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @sd123
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia __i.am.prashant__

    __i.am.prashant__ โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sakthi_dev

    @sd123, Could you please share the steps to reproduce it with the details like version and all. Not able to reproduce the mentioned issue.
    Drupal Version: 10.1
    PHP Version: 8.1

  • I did some testing and it happens each time someone presses the preview button on the contact form.

    As a workaround, I just removed the preview feature from my site.

    PHP 8.2.7
    Drupal 10.2.3

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia __i.am.prashant__

    Hello @sd123,
    I attempted to replicate the problem using PHP 8.2 and Drupal 10.2.3, but I was unable to do so. Could you kindly explain in brief how I can replicate the problem? If it's feasible, please include a gif or image.

  • Assigned to Mohd Sahzad
  • Merge request !8fixed Passing null to parameter โ†’ (Open) created by Mohd Sahzad
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 5.7
    last update 4 months ago
    9 pass
  • Status changed to Needs review 4 months ago
  • Step 1:

    Step 2:

    This is logged when pressing the Preview button:

    Deprecated function: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in Drupal\color\ColorSystemBrandingBlockAlter::preRender() (line 27 of /PATH/TO/SITE/web/modules/contrib/color/src/ColorSystemBrandingBlockAlter.php) #0 /PATH/TO/SITE/web/core/includes/bootstrap.inc(164): _drupal_error_handler_real()
    feb 14 11:25:03 vps1 drupal[512150]: #1 [internal function]: _drupal_error_handler()
    feb 14 11:25:03 vps1 drupal[512150]: #2 /PATH/TO/SITE/web/modules/contrib/color/src/ColorSystemBrandingBlockAlter.php(27): preg_match()
    feb 14 11:25:03 vps1 drupal[512150]: #3 [internal function]: Drupal\color\ColorSystemBrandingBlockAlter::preRender()
    feb 14 11:25:03 vps1 drupal[512150]: #4 /PATH/TO/SITE/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(111): call_user_func_array()
    <snip>
  • Ok, I am also getting the error without the Preview button. This is how I can trigger the error in the logs:

    1. Put a space only in the Subject field.
    2. Enter something in all other fields.
    3. Press the Send message button.
    4. The error "Subject field is required." appears on the screen + Deprecated function: preg_match() in ColorSystemBrandingBlockAlter.php is logged.
  • I can reproduce this too using Drupal 10.2.4 and color 1.0.3.

    1. Select a theme that supports the color module (such as bartik)
    2. Select a non-default color scheme
    3. Remove the site logo by unchecking "Use the logo supplied by the theme".
    4. Save the color settings.
    5. Visit the site home page.

    The error appears in the log (or on the screen, depending on error reporting settings).

  • The merge request from #7 fixes the issue for me.

  • Status changed to RTBC 3 months ago
  • Oops, I overlooked that merge request.

    I can confirm it also fixes the issue for me.

  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to Needs work 2 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    The steps to reproduce this bug needs to be put in the issue summary, not in various comments.

Production build 0.69.0 2024