Skip to content

Commit fc4904a

Browse files
[5.x] Prevent using the reserved horizon Redis connection name (#1615)
* feat: prevent using horizon redis connection name * refactor: move checkIsReservedConnectionName method to service provider * formatting --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 5848cbe commit fc4904a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/HorizonServiceProvider.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Queue\QueueManager;
88
use Illuminate\Support\Facades\Route;
99
use Illuminate\Support\ServiceProvider;
10+
use InvalidArgumentException;
1011
use Laravel\Horizon\Connectors\RedisConnector;
1112

1213
class HorizonServiceProvider extends ServiceProvider
@@ -159,7 +160,15 @@ protected function configure()
159160
__DIR__.'/../config/horizon.php', 'horizon'
160161
);
161162

162-
Horizon::use(config('horizon.use', 'default'));
163+
$connection = config('horizon.use', 'default');
164+
165+
if ($connection === 'horizon' || config()->has('database.redis.horizon')) {
166+
throw new InvalidArgumentException(
167+
'The Redis connection name [horizon] is reserved for internal use.'
168+
);
169+
}
170+
171+
Horizon::use($connection);
163172
}
164173

165174
/**

0 commit comments

Comments
 (0)