Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: prevent using horizon redis connection name
  • Loading branch information
amirhshokri committed Oct 3, 2025
commit 546753d84ed04c9ffcd5be5ac2cdaa61c8b0126e
18 changes: 18 additions & 0 deletions src/Horizon.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Exception;
use Illuminate\Support\HtmlString;
use Illuminate\Support\Js;
use InvalidArgumentException;
use RuntimeException;

class Horizon
Expand Down Expand Up @@ -90,6 +91,23 @@ public static function auth(Closure $callback)
return new static;
}

/**
* Check if a given Redis connection name is reserved by Horizon.
*
* @param string $connection
* @return void
*
* @throws \Exception
*/
public static function checkReservedConnectionName(string $connection): void
{
if ($connection === 'horizon' || config()->has('database.redis.horizon')) {
throw new InvalidArgumentException(
'The Redis connection name [horizon] is reserved for internal use.'
);
}
}

/**
* Configure the Redis databases that will store Horizon data.
*
Expand Down
2 changes: 2 additions & 0 deletions src/HorizonServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ protected function configure()
__DIR__.'/../config/horizon.php', 'horizon'
);

Horizon::checkReservedConnectionName(config('horizon.use', 'default'));

Horizon::use(config('horizon.use', 'default'));
}

Expand Down