Problem/Motivation

When I use a colorbox video formatter and I do not have the image style defined, then the following errors appear:

Deprecated function: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in template_preprocess_colorbox_media_remote_video_formatter() (line 83 of /mnt/www/html/server/docroot/modules/contrib/colorbox_media_video/colorbox_media_video.theme.inc)#0 /mnt/www/html/server/docroot/core/includes/bootstrap.inc(346): _drupal_error_handler_real(8192, 'strpos(): Passi...', '/mnt/www/html/d...', 83)
#1 [internal function]: _drupal_error_handler(8192, 'strpos(): Passi...', '/mnt/www/html/d...', 83)
#2 /mnt/www/html/server/docroot/modules/contrib/colorbox_media_video/colorbox_media_video.theme.inc(83): strpos(NULL, 'colorbox/exampl...')
#3 /mnt/www/html/server/docroot/core/lib/Drupal/Core/Theme/ThemeManager.php(287): template_preprocess_colorbox_media_remote_video_formatter(Array, 'colorbox_media_...', Array) 

and the item thumb has the title empty:

Deprecated function: mb_strlen(): Passing null to parameter #1 ($string) of type string is deprecated in template_preprocess_colorbox_media_remote_video_formatter() (line 152 of /mnt/www/html/server/docroot/modules/contrib/colorbox_media_video/colorbox_media_video.theme.inc)#0 /mnt/www/html/server/docroot/core/includes/bootstrap.inc(346): _drupal_error_handler_real(8192, 'mb_strlen(): Pa...', '/mnt/www/html/d...', 152)
#1 [internal function]: _drupal_error_handler(8192, 'mb_strlen(): Pa...', '/mnt/www/html/d...', 152)
#2 /mnt/www/html/server/docroot/modules/contrib/colorbox_media_video/colorbox_media_video.theme.inc(152): mb_strlen(NULL)
#3 /mnt/www/html/server/docroot/core/lib/Drupal/Core/Theme/ThemeManager.php(287): template_preprocess_colorbox_media_remote_video_formatter(Array, 'colorbox_media_...', Array)
#4 /mnt/www/html/server/docroot/core/lib/Drupal/Core/Render/Renderer.php(422): Drupal\Core\Theme\ThemeManager->render('colorbox_media_...', Array)
#5 /mnt/www/html/server/docroot/core/lib/Drupal/Core/Render/Renderer.php(201): Drupal\Core\Render\Renderer->doRender(Array, false) 

Steps to reproduce

It happens on drupal 9.4.5 with PHP 8.1 when visiting a basic page with a field configured with the colobox video formatter.

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Eduardo Morales Alberti’s picture

Status: Active » Needs review

Convert variables into strings to avoid null values and the PHP 8 deprecated error.

kenrbnsn’s picture

Can you post a patch so the file can be patched via composer?

Eduardo Morales Alberti’s picture

FileSize
29.62 KB

Hi @kenrbnsn, you can download a patch of the Merge Request clicking on "plain_diff" then, saving it to a folder in your project, example ./patches/3305654-deprecated-php8.patch, and then applying it via composer.
Plain diff

kenrbnsn’s picture

I know that, but it's much easier if a patch file is published in this issue so it can be picked up with a link. Why should multiple people have to do these steps?

Eduardo Morales Alberti’s picture

I know that until the issue GitLab Merge Requests Unable to Generate Incremental Patch Files is resolved, downloading the patch is a pain.

Feel free to upload the patch of the MR if you need it and think other people will need it.

Eduardo Morales Alberti’s picture

Issue summary: View changes
johnpicozzi’s picture

@kenrbnsn you can use the plain diff button above and change .diff to .patch in the url to use this in your composer file. It isn't without it's potential issues, but it works.

I was able to test the patch above and it resolved the php errors in my logs. RTBC+1

levmyshkin’s picture

It's working good for me. Drupal 9.4.7.

levmyshkin’s picture

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

In case anyone else likes to add patch files from drupal.org into their composer files, here is the patch file.

tamerzg’s picture

Commited to 2.0.1

tamerzg’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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