Problem/Motivation

If we set the retry enabled to false in the settings UI, it has no effect. It still executes the retry.

Steps to reproduce

Just install the module and go to the system settings. Just disable the Enable retries setting. Then execute a client request that runs in an error.

Note: If you pass retry_enabled => FALSE to the options, it works.

Proposed resolution

In the class, src/HTTP/HttpClientMiddleware.php do not use the array_filter function. It filters all false values. But we want false here. The next line, then, sets the value to true.

We have PHP 8.1 in place in our installation.

I will provide a patch.

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:

Comments

danielspeicher created an issue. See original summary.

danielspeicher’s picture

Status: Active » Needs review
wells’s picture

Status: Needs review » Needs work

Hm yes I can see how array_filter causes an issue here. However we can't just remove it because NULLs in the default config will inadvertently override defaults in the client. We need a solution here booleans but filters NULLs, I think?

danielspeicher’s picture

Yes, you are right. I will provide a solution.

danielspeicher’s picture

Status: Needs work » Needs review

I have added a function to filter just null values.

wells’s picture

Status: Needs review » Needs work
danielspeicher’s picture

Status: Needs work » Needs review

Shorthand function added.

wells’s picture

Status: Needs review » Needs work
danielspeicher’s picture

Then I need help. My phpcs is clean with official Drupal profile.

Let us save time and effort, so I propose, that you resolve this open thread.

wells’s picture

@danielspeicher you may want to inspect your phpcs config. Here is the output from your branch:

~/PhpstormProjects/http_client_retry 3358215-set-retry-enabled > vendor/bin/phpcs                                 
.................E. 19 / 19 (100%)

FILE: src/Http/HttpClientMiddleware.php
-------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------
 78 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
-------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------

Time: 2.52 secs; Memory: 14MB

Anyway yeah I'll put in a quick fix for this before merge. Thank you!

wells’s picture

Status: Needs work » Fixed
danielspeicher’s picture

Thank you very much. I will check our config.

Status: Fixed » Closed (fixed)

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