Skip to content

fix(starter): Redis drop-in fatal when REDIS_PORT is unset - #17

Merged
palicko merged 1 commit into
mainfrom
fix/redis-config
Oct 22, 2026
Merged

palicko merged 1 commit into
mainfrom
fix/redis-config

Conversation

@palicko

@palicko palicko commented Oct 22, 2026

Copy link
Copy Markdown
Member

Problem

config/application.php defined WP_REDIS_HOST/WP_REDIS_PORT as env(...) ?? ''. When the environment has no REDIS_PORT (the default on SpinupWP), the drop-in gets '' instead of its 127.0.0.1:6379 defaults, and phpredis fatals:

TypeError: Redis::connect(): Argument #2 ($port) must be of type int, string given

Hit on apollobc.sk when enabling the Redis drop-in. Projects without the drop-in never notice, but 14 local projects carry the same lines.

Separately, many sites share one Redis db (db0) on a server. Without WP_REDIS_SELECTIVE_FLUSH, the SpinupWP drop-in's wp_cache_flush() runs FLUSHDB and wipes every site's cache.

Change

  • Define WP_REDIS_HOST/WP_REDIS_PORT only when set; cast the port to int.
  • WP_REDIS_SELECTIVE_FLUSH defaults to true; setting WP_REDIS_SELECTIVE_FLUSH=false opts out.
  • Applied to packages/webentor-starter and its test-site mirror.

Verification

  • php -l on both files.
  • Ran the block through Bedrock's env(): unset/empty host+port leave the constants undefined; REDIS_PORT=6380 gives int 6380; selective flush is true by default and false with the opt-out.
  • Same fix is live on apollobc.sk: constants undefined on prod, WP_REDIS_SELECTIVE_FLUSH=true.

No starter release in this PR; existing projects need the change applied by hand or via the next starter release.

https://claude.ai/code/session_01N2CKAdb8iZMn5mbymAy6Bc

Define WP_REDIS_HOST/PORT only when set (port as int), so the drop-in's
127.0.0.1:6379 defaults apply. Enable selective flush by default for
shared Redis dbs; WP_REDIS_SELECTIVE_FLUSH=false opts out.

Claude-Session: https://claude.ai/code/session_01N2CKAdb8iZMn5mbymAy6Bc
@palicko
palicko merged commit fc75c32 into main Oct 22, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant