Replaced working redis with version 2 alpha - rebuilt cache with drush - it threw

Error: Class "Drupal\redis\Client\PhpRedisFactory" not found in Drupal\Component\DependencyInjection\Container->createService() (line 261 of /var/www/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php  
The website encountered an unexpected error. Try again later.
TypeError: RateLimit\RedisRateLimiter::__construct(): Argument #2 ($redis) must be of type Redis, Drupal\redis\Client\PhpRedis given, called in /var/www/public_html/modules/crawler_rate_limit/src/RateLimitBackendFactory.php on line 98 in RateLimit\RedisRateLimiter->__construct() (line 18 of vendor/nikolaposa/rate-limit/src/RedisRateLimiter.php).RateLimit\RedisRateLimiter->__construct() (Line: 98)Drupal\crawler_rate_limit\RateLimitBackendFactory->getRedis() (Line: 62)Drupal\crawler_rate_limit\RateLimitBackendFactory->get() (Line: 216)Drupal\crawler_rate_limit\RateLimitManager->limitReached() (Line: 270)Drupal\crawler_rate_limit\RateLimitManager->limit() (Line: 50)Drupal\crawler_rate_limit\CrawlerRateLimitMiddleware->handle() (Line: 61)Drupal\advban\AdvbanMiddleware->handle() (Line: 50)Drupal\ban\BanMiddleware->handle() (Line: 48)Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)Drupal\Core\DrupalKernel->handle() (Line: 19)

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

bobburns created an issue. See original summary.

berdir’s picture

You are using another module that relies on redis, that needs to be updated: crawler_rate_limit. You need to report this there.

berdir’s picture

Project: Redis » Crawler Rate Limit
Version: 2.0.0-alpha1 » 3.x-dev

Moving to that project.

johannesjvorstermans’s picture

StatusFileSize
new6.78 KB

Attached is a Patch

What the Patch Changes
Only the getRedis() method is modified (lines 95-108 in the original). Instead of passing $client directly to RedisRateLimiter, it now calls extractRawRedisClient($client) which:

If the client is already a raw \Redis or \Predis\ClientInterface (Redis 1.x), returns it as-is

If it's a Redis 2.x adapter, uses reflection to access the protected $redis property and returns the underlying native client

This works for both PhpRedis and Predis configurations. No other changes were made to the file.

ressa’s picture

Status: Active » Needs work

Thanks @johannesjvorstermans, maybe you can create a GitLab Merge Request? https://www.drupal.org/docs/develop/git/using-gitlab-to-contribute-to-dr...

vaish made their first commit to this issue’s fork.

vaish’s picture

Title: Upgrade error - Client\PhpRedisFactory not found » Add support for version two of Redis module
Component: User interface » Code
Assigned: Unassigned » vaish

Thanks for the patch @johannesjvorstermans. I created a GitLab MR from your patch. Planning to make some tweaks to it before merging.

vaish’s picture

Status: Needs work » Needs review

  • vaish committed 7f2f7237 on 3.x
    feat: #3565789 Add support for version two of Redis module
    
    By: bobburns...
vaish’s picture

Assigned: vaish » Unassigned
Category: Bug report » Feature request
Status: Needs review » Fixed

Merged. Thanks everyone.

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.

Status: Fixed » Closed (fixed)

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