Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#12 | colorbox_media_video-3305654.patch | 1.3 KB | kenrbnsn |
#5 | palin_diff.png | 29.62 KB | Eduardo Morales Alberti |
Issue fork colorbox_media_video-3305654
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
Comment #3
Eduardo Morales AlbertiConvert variables into strings to avoid null values and the PHP 8 deprecated error.
Comment #4
kenrbnsn CreditAttribution: kenrbnsn commentedCan you post a patch so the file can be patched via composer?
Comment #5
Eduardo Morales AlbertiHi @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.
Comment #6
kenrbnsn CreditAttribution: kenrbnsn commentedI 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?
Comment #7
Eduardo Morales AlbertiI 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.
Comment #8
Eduardo Morales AlbertiComment #9
johnpicozzi@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
Comment #10
levmyshkinIt's working good for me. Drupal 9.4.7.
Comment #11
levmyshkinComment #12
kenrbnsn CreditAttribution: kenrbnsn commentedIn case anyone else likes to add patch files from drupal.org into their composer files, here is the patch file.
Comment #13
tamerzg CreditAttribution: tamerzg at Websolutions Agency commentedCommited to 2.0.1
Comment #14
tamerzg CreditAttribution: tamerzg at Websolutions Agency commented