Passing null to parameter #2 ($string2) of type string is deprecated in ReCaptcha\ReCaptcha->verify()

Created on 2 July 2022, over 2 years ago
Updated 18 July 2023, over 1 year ago

Problem/Motivation

Issue with PHP 8.1 ? I'm not sure if this is a recaptcha_v3 or recaptcha issue as I cant seem to find report in either queue.

I get the following after updating to PHP 8.1

Deprecated function: strcasecmp(): Passing null to parameter #2 ($string2) of type string is deprecated in ReCaptcha\ReCaptcha->verify() (line 168 of /home/ipmsusa3/public_html/drupal9/vendor/google/recaptcha/src/ReCaptcha/ReCaptcha.php)
#0 /home/ipmsusa3/public_html/drupal9/core/includes/bootstrap.inc(347): _drupal_error_handler_real(8192, 'strcasecmp(): P...', '/home/ipmsusa3/...', 168)
#1 [internal function]: _drupal_error_handler(8192, 'strcasecmp(): P...', '/home/ipmsusa3/...', 168)
#2 /home/ipmsusa3/public_html/drupal9/vendor/google/recaptcha/src/ReCaptcha/ReCaptcha.php(168): strcasecmp('reviews.ipmsusa...', NULL)
#3 /home/ipmsusa3/public_html/drupal9/modules/contrib/recaptcha_v3/recaptcha_v3.module(321): ReCaptcha\ReCaptcha->verify('Google no captc...', '185.61.216.89')
#4 /home/ipmsusa3/public_html/drupal9/modules/contrib/recaptcha_v3/recaptcha_v3.module(222): _recaptcha_v3_verify_captcha_response(Object(Drupal\recaptcha_v3\Entity\ReCaptchaV3Action), 'Google no captc...')
#5 /home/ipmsusa3/public_html/drupal9/modules/contrib/captcha/captcha.module(512): recaptcha_v3_validate(false, 'Google no captc...', Array, Object(Drupal\Core\Form\FormState))
#6 [internal function]: captcha_validate(Array, Object(Drupal\Core\Form\FormState), Array)
#7 /home/ipmsusa3/public_html/drupal9/core/lib/Drupal/Core/Form/FormValidator.php(282): call_user_func_array('captcha_validat...', Array)
#8 /home/ipmsusa3/public_html/drupal9/core/lib/Drupal/Core/Form/FormValidator.php(238): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState))
#9 /home/ipmsusa3/public_html/drupal9/core/lib/Drupal/Core/Form/FormValidator.php(118): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'comment_comment...')
#10 /home/ipmsusa3/public_html/drupal9/core/lib/Drupal/Core/Form/FormBuilder.php(588): Drupal\Core\Form\FormValidator->validateForm('comment_comment...', Array, Object(Drupal\Core\Form\FormState))
#11 /home/ipmsusa3/public_html/drupal9/core/lib/Drupal/Core/Form/FormBuilder.php(320): Drupal\Core\Form\FormBuilder->processForm('comment_comment...', Array, Object(Drupal\Core\Form\FormState))
#12 /home/ipmsusa3/public_html/drupal9/core/lib/Drupal/Core/Entity/EntityFormBuilder.php(48): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\comment\CommentForm), Object(Drupal\Core\Form\FormState))
#13 /home/ipmsusa3/public_html/drupal9/core/modules/comment/src/Controller/CommentController.php(267): Drupal\Core\Entity\EntityFormBuilder->getForm(Object(Drupal\comment\Entity\Comment))
#14 [internal function]: Drupal\comment\Controller\CommentController->getReplyForm(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\node\Entity\Node), 'comment_node_re...', NULL)
#15 /home/ipmsusa3/public_html/drupal9/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#16 /home/ipmsusa3/public_html/drupal9/core/lib/Drupal/Core/Render/Renderer.php(564): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#17 /home/ipmsusa3/public_html/drupal9/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#18 /home/ipmsusa3/public_html/drupal9/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#19 /home/ipmsusa3/public_html/drupal9/vendor/symfony/http-kernel/HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#20 /home/ipmsusa3/public_html/drupal9/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#21 /home/ipmsusa3/public_html/drupal9/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /home/ipmsusa3/public_html/drupal9/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /home/ipmsusa3/public_html/drupal9/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /home/ipmsusa3/public_html/drupal9/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /home/ipmsusa3/public_html/drupal9/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /home/ipmsusa3/public_html/drupal9/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 /home/ipmsusa3/public_html/drupal9/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 /home/ipmsusa3/public_html/drupal9/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 /home/ipmsusa3/public_html/drupal9/core/lib/Drupal/Core/DrupalKernel.php(709): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 /home/ipmsusa3/public_html/drupal9/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#31 {main}

Steps to reproduce

Update to PHP 8.1

πŸ› Bug report
Status

Closed: works as designed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States aitala

Live updates comments and jobs are added and updated live.
  • PHP 8.1

    The issue particularly affects sites running on PHP version 8.1.0 or later.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡§πŸ‡ͺBelgium ericvl

    Hallo,

    There is a new version of the google/recaptcha package since Feb. 18th. It's version 1.3.0.
    This is the version that should be compatible with PHP 8.
    Should it not ne advisable to make a new version of this package here that is dependent on ^1.3 in stead of ^1.2?
    We need this to be compatible with Drupal 10.
    Greetings.

  • Status changed to Postponed almost 2 years ago
  • πŸ‡ΊπŸ‡¦Ukraine dench0

    @EricVL

    I don't think that doing it now is a good idea.

    In the recaptcha "README.md" stated:

    The 1.3 release moves to PHP 8 and up. For earlier versions, you will need to stay with the 1.2 releases.

    So I'm not sure if 1.3 is compatible with PHP7 and we need to think about sites that still use PHP 7. Otherwise, it will block such sites from all future module updates.

    In the future, we definitely increase it, but not now.

  • Status changed to Closed: works as designed over 1 year ago
  • πŸ‡¨πŸ‡­Switzerland GRcwolf

    I would propose to close the issue.

    It appears that version 2.0.x of this module already requires at least version 1.3 of google/recaptcha.
    See the composer.json

    The version 1.x of this module version requires "^1.2" of google/recaptcha.
    So that means that it already allows using version 1.3.x of google/recaptcha. Composer should therefore already be downloading version 1.3.0 at least as long as all its requirements are met, and no other packages require another version.

Production build 0.71.5 2024