When I try add a new key I get the following error.:
Couldn't connect to the Brevo API. Please check your API settings.

PHP 8.5

I'm not sure what else to actually try.

Error message:

Deprecated function: Brevo\Client\Api\AccountApi::__construct(): Implicitly marking parameter $selector as nullable is deprecated, the explicit nullable type must be used instead in include() (line 576 of {redacted}vendor/composer/ClassLoader.php)

#0 {redacted}web/core/includes/bootstrap.inc(104): _drupal_error_handler_real()
#1 {redacted}vendor/composer/ClassLoader.php(576): _drupal_error_handler()
#2 {redacted}vendor/composer/ClassLoader.php(576): include('...')
#3 {redacted}vendor/composer/ClassLoader.php(427): {closure:Composer\Autoload\ClassLoader::initializeIncludeClosure():575}()
#4 {redacted}web/modules/contrib/brevo/src/BrevoFactory.php(97): Composer\Autoload\ClassLoader->loadClass()
#5 {redacted}web/modules/contrib/brevo/src/BrevoHandler.php(87): Drupal\brevo\BrevoFactory->createAccountApiClient()
#6 {redacted}web/modules/contrib/brevo/src/Form/BrevoAdminSettingsForm.php(70): Drupal\brevo\BrevoHandler->validateBrevoApiKey()
#7 {redacted}web/core/lib/Drupal/Core/Form/FormValidator.php(87): Drupal\brevo\Form\BrevoAdminSettingsForm->validateForm()
#8 {redacted}web/core/lib/Drupal/Core/Form/FormValidator.php(280): Drupal\Core\Form\FormValidator->executeValidateHandlers()
#9 {redacted}web/core/lib/Drupal/Core/Form/FormValidator.php(123): Drupal\Core\Form\FormValidator->doValidateForm()
#10 {redacted}web/modules/contrib/autosave_form/src/Form/AutosaveFormValidator.php(69): Drupal\Core\Form\FormValidator->validateForm()
#11 {redacted}web/core/lib/Drupal/Core/Form/FormBuilder.php(611): Drupal\autosave_form\Form\AutosaveFormValidator->validateForm()
#12 {redacted}web/modules/contrib/autosave_form/src/Form/AutosaveFormBuilder.php(144): Drupal\Core\Form\FormBuilder->processForm()
#13 {redacted}web/core/lib/Drupal/Core/Form/FormBuilder.php(347): Drupal\autosave_form\Form\AutosaveFormBuilder->processForm()
#14 {redacted}web/modules/contrib/autosave_form/src/Form/AutosaveFormBuilder.php(97): Drupal\Core\Form\FormBuilder->buildForm()
#15 {redacted}web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\autosave_form\Form\AutosaveFormBuilder->buildForm()
#16 [internal function]: Drupal\Core\Controller\FormController->getContentResult()
#17 {redacted}web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#18 {redacted}web/core/lib/Drupal/Core/Render/Renderer.php(634): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->{closure:Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::wrapControllerExecutionInRenderContext():121}()
#19 [internal function]: Drupal\Core\Render\Renderer::{closure:Drupal\Core\Render\Renderer::executeInRenderContext():634}()
#20 {redacted}web/core/lib/Drupal/Core/Render/Renderer.php(635): Fiber->start()
#21 {redacted}web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#22 {redacted}web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#23 {redacted}vendor/symfony/http-kernel/HttpKernel.php(183): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->{closure:Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::onController():96}()
#24 {redacted}vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#25 {redacted}web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#26 {redacted}web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#27 {redacted}web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#28 {redacted}web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#29 {redacted}web/core/modules/page_cache/src/StackMiddleware/PageCache.php(118): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#30 {redacted}web/core/modules/page_cache/src/StackMiddleware/PageCache.php(92): Drupal\page_cache\StackMiddleware\PageCache->pass()
#31 {redacted}web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#32 {redacted}web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#33 {redacted}web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(53): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#34 {redacted}web/modules/contrib/cloudflare/src/CloudFlareMiddleware.php(124): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#35 {redacted}web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(54): Drupal\cloudflare\CloudFlareMiddleware->handle()
#36 {redacted}web/core/lib/Drupal/Core/DrupalKernel.php(745): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#37 {redacted}web/index.php(19): Drupal\Core\DrupalKernel->handle()
#38 {main}

Comments

alabandit created an issue. See original summary.

renrhaf’s picture

Thanks for reporting this issue.

This is caused by the Brevo PHP SDK (getbrevo/brevo-php) using implicit nullable parameters, which triggers a deprecation warning in PHP 8.4+. Drupal's error handler catches this deprecation and the module's exception handling wasn't
catching this type of error.

I've committed a fix that changes the exception handling to catch \Throwable instead of just ApiException, which will gracefully handle these deprecation errors until the upstream SDK is fixed.

Unfortunately, there's no fixed version of the Brevo PHP SDK available yet. There are several open pull requests on the SDK repository that address this issue, but none have been merged:
- https://github.com/getbrevo/brevo-php/pull/82
- https://github.com/getbrevo/brevo-php/pull/93

The fix should be available in the next release. In the meantime, you can apply the patch from the latest dev version, or wait for the 1.0.5 release.

  • renrhaf committed 09af133b on 1.0.x
    Issue #3570882 by renrhaf: Fix PHP 8.5 compatibility with Brevo SDK...
renrhaf’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

alabandit’s picture

Thank you, that worked for me

Status: Fixed » Closed (fixed)

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