str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in modal_page_preprocess_html() (line 159

Created on 22 February 2023, about 2 years ago
Updated 10 March 2023, almost 2 years ago
Deprecated function: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in modal_page_preprocess_html() (line 159 of modules/contrib/modal_page/modal_page.module).
modal_page_preprocess_html(Array, 'html', Array)
🐛 Bug report
Status

RTBC

Version

5.0

Component

Code

Created by

🇻🇳Vietnam mrddthi

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

Comments & Activities

  • Issue created by @mrddthi
  • Issue was unassigned.
  • Status changed to Needs work about 2 years ago
  • 🇧🇷Brazil renatog Campinas

    Thank you so much for the contribution

    +++ b/modal_page.module
    @@ -155,13 +155,15 @@ function modal_page_preprocess_html(&$variables) {
    +    if ($modalVideoLink) {
    

    On this case I'd suggest verify with !empty and I think we can join the Ifs, for example:

    if (!empty($modalVideoLink) && (str_contains($modalVideoLink, "watch?v=") || str_contains($modalVideoLink, ".be"))) {
      $modalVideoLink = str_replace(
        ["watch?v=", ".be"],
        ["embed/", "be.com/embed"],
        $modalVideoLink
      );
    }
    
  • First commit to issue fork.
  • @adminazhar opened merge request.
  • Status changed to Needs review almost 2 years ago
  • 🇺🇸United States bygeoffthompson

    Patch resolves the `str_contains()` Drupal error seen on my website (same as in issue description). Thanks for this!

    • Drupal 9.5.2
    • Modal Page 5.0.1
    • PHP 8.1.3

    RTBC

  • Status changed to RTBC almost 2 years ago
Production build 0.71.5 2024