Skip to content

Commit 5a95a3a

Browse files
committed
Fix environment script to not explode when default option isn't in array.
1 parent d0ad3ad commit 5a95a3a

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

app/Console/Commands/UpdateEnvironment.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,40 +130,49 @@ public function handle()
130130
}
131131

132132
if (is_null($this->option('driver'))) {
133-
$this->line('If you chose redis as your cache driver backend, you *must* have a redis server configured already.');
134-
$variables['CACHE_DRIVER'] = $this->choice('Which cache driver backend would you like to use?', [
133+
$options = [
135134
'memcached' => 'Memcache',
136135
'redis' => 'Redis (recommended)',
137136
'apc' => 'APC',
138137
'array' => 'PHP Array',
139-
], config('cache.default', 'memcached'));
138+
];
139+
$default = (in_array($options, config('cache.default', 'memcached'))) ? config('cache.default', 'memcached') : 'memcached';
140+
141+
$this->line('If you chose redis as your cache driver backend, you *must* have a redis server configured already.');
142+
$variables['CACHE_DRIVER'] = $this->choice('Which cache driver backend would you like to use?', $options, $default);
140143
} else {
141144
$variables['CACHE_DRIVER'] = $this->option('driver');
142145
}
143146

144147
if (is_null($this->option('session-driver'))) {
145-
$this->line('If you chose redis as your cache driver backend, you *must* have a redis server configured already.');
146-
$variables['SESSION_DRIVER'] = $this->choice('Which session driver backend would you like to use?', [
148+
$options = [
147149
'database' => 'MySQL (recommended)',
148150
'redis' => 'Redis',
149151
'file' => 'File',
150152
'cookie' => 'Cookie',
151153
'apc' => 'APC',
152154
'array' => 'PHP Array',
153-
], config('session.driver', 'database'));
155+
];
156+
$default = (in_array($options, config('session.driver', 'database'))) ? config('cache.default', 'database') : 'database';
157+
158+
$this->line('If you chose redis as your cache driver backend, you *must* have a redis server configured already.');
159+
$variables['SESSION_DRIVER'] = $this->choice('Which session driver backend would you like to use?', $options, $default);
154160
} else {
155161
$variables['SESSION_DRIVER'] = $this->option('session-driver');
156162
}
157163

158164
if (is_null($this->option('queue-driver'))) {
159-
$this->line('If you chose redis as your cache driver backend, you *must* have a redis server configured already.');
160-
$variables['QUEUE_DRIVER'] = $this->choice('Which cache driver backend would you like to use?', [
165+
$options = [
161166
'database' => 'Database (recommended)',
162167
'redis' => 'Redis',
163168
'sqs' => 'Amazon SQS',
164169
'sync' => 'Sync',
165170
'null' => 'None',
166-
], config('queue.driver', 'database'));
171+
];
172+
$default = (in_array($options, config('queue.driver', 'database'))) ? config('queue.driver', 'database') : 'database';
173+
174+
$this->line('If you chose redis as your cache driver backend, you *must* have a redis server configured already.');
175+
$variables['QUEUE_DRIVER'] = $this->choice('Which cache driver backend would you like to use?', $options, $default);
167176
} else {
168177
$variables['QUEUE_DRIVER'] = $this->option('queue-driver');
169178
}

0 commit comments

Comments
 (0)