Wrong return values for the MailjetHandler class functions

Created on 7 March 2022, almost 3 years ago
Updated 20 July 2023, over 1 year ago

Problem/Motivation

Class MailjetHandler contains function with wrong return values. All function from this class has the type hint for the return value ?array but most of them can return FALSE.

Steps to reproduce

In my case after running post_update which change user field values and saves user entity, I got the following error:
TypeError: Return value of Drupal\mailjet\MailjetHandler::syncMailjetContact() must be of the type array or null, bool returned in Drupal\mailjet\MailjetHandler->syncMailjetContact() (line 251 of /var/www/html/web/modules/contrib/mailjet/src/MailjetHandler.php).

Proposed resolution

Replace return value for these functions from the FALSE to NULL

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine _shy Ukraine, Lutsk πŸ‡ΊπŸ‡¦

Live updates comments and jobs are added and updated live.
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.

  • πŸ‡©πŸ‡ͺGermany TipiT Hamburg

    After applying this patch to alpha2 I started getting these errors instead:

    Warning: Array to string conversion in Mailjet\Client->buildURL() (line 251 of vendor/mailjet/mailjet-apiv3-php/src/Mailjet/Client.php) #0 web/core/includes/bootstrap.inc(347): _drupal_error_handler_real()
    Jul 20 12:19:07 ip-172-31-7-225 drupal: #1 [internal function]: _drupal_error_handler()
    Jul 20 12:19:07 ip-172-31-7-225 drupal: #2 vendor/mailjet/mailjet-apiv3-php/src/Mailjet/Client.php(251): join()
    Jul 20 12:19:07 ip-172-31-7-225 drupal: #3 vendor/mailjet/mailjet-apiv3-php/src/Mailjet/Client.php(117): Mailjet\Client->buildURL()
    Jul 20 12:19:07 ip-172-31-7-225 drupal: #4 vendor/mailjet/mailjet-apiv3-php/src/Mailjet/Client.php(169): Mailjet\Client->_call()
    Jul 20 12:19:07 ip-172-31-7-225 drupal: #5 web/modules/contrib/mailjet/src/MailjetHandler.php(245): Mailjet\Client->post()
    Jul 20 12:19:07 ip-172-31-7-225 drupal: #6 web/modules/contrib/mailjet/mailjet.module(465): Drupal\mailjet\MailjetHandler->syncMailjetContact()
    Jul 20 12:19:07 ip-172-31-7-225 drupal: #7 web/modules/contrib/mailjet/mailjet.module(404): mailjet_sync_single_user()
    Jul 20 12:19:07 ip-172-31-7-225 drupal: #8 [internal function]: mailjet_user_delete()
    
    
    TypeError: htmlspecialchars(): Argument #1 ($string) must be of type string, array given in htmlspecialchars() (line 432 of web/core/lib/Drupal/Component/Utility/Html.php) 
    #0 web/core/lib/Drupal/Component/Utility/Html.php(432): htmlspecialchars()
    Jul 20 12:19:07 ip-172-31-7-225 drupal: #1 web/core/lib/Drupal/Component/Render/FormattableMarkup.php(270): Drupal\Component\Utility\Html::escape()
    Jul 20 12:19:07 ip-172-31-7-225 drupal: #2 web/core/lib/Drupal/Component/Render/FormattableMarkup.php(216): Drupal\Component\Render\FormattableMarkup::placeholderEscape()
    Jul 20 12:19:07 ip-172-31-7-225 drupal: #3 web/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php(195): Drupal\Component\Render\FormattableMarkup::placeholderFormat()
    Jul 20 12:19:07 ip-172-31-7-225 drupal: #4 web/core/lib/Drupal/Component/Utility/ToStringTrait.php(15): Drupal\Core\StringTranslation\TranslatableMarkup->render()
    Jul 20 12:19:07 ip-172-31-7-225 drupal: #5 [internal function]: Drupal\Core\StringTranslation\TranslatableMarkup->__toString()
    Jul 20 12:19:07 ip-172-31-7-225 drupal: #6 web/core/lib/Drupal/Core/Logger/LogMessageParser.php(16): strpos()
    Jul 20 12:19:07 ip-172-31-7-225 drupal: #7 web/core/modules/syslog/src/Logger/SysLog.php(78): Drupal\Core\Logger\LogMessageParser->parseMessagePlaceholders()
    Jul 20 12:19:07 ip-172-31-7-225 drupal: #8 web/core/lib/Drupal/Core/Logger/LoggerChannel.php(127): Drupal\syslog\Logger\SysLog->log()
    Jul 20 12:19:07 ip-172-31-7-225 drupal: #9 vendor/psr/log/Psr/Log/LoggerTrait.php(99): Drupal\Core\Logger\LoggerChannel->log()
    Jul 20 12:19:07 ip-172-31-7-225 drupal: #10 web/modules/contrib/mailjet/mailjet.module(468): Drupal\Core\Logger\LoggerChannel->notice()
    Jul 20 12:19:07 ip-172-31-7-225 drupal: #11 web/modules/contrib/mailjet/mailjet.module(404): mailjet_sync_single_user()
    Jul 20 12:19:07 ip-172-31-7-225 drupal: #12 [internal function]: mailjet_user_delete()

    So the question is, does this patch actually fix the issue or just return different values?

    I get the error when trying to delete a user account and it obviously fail.

Production build 0.71.5 2024