Skip to content

Commit 140298b

Browse files
committed
Updated to Laravel 5.8
1 parent 58f5508 commit 140298b

65 files changed

Lines changed: 282 additions & 767 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ before_script:
2323
- php artisan migrate --force -n --database=mysql_testing
2424
- php artisan db:seed --force -n --class=DummyContentSeeder --database=mysql_testing
2525

26+
script: vendor/bin/phpunit --configuration phpunit.xml
27+
2628
after_failure:
2729
- cat storage/logs/laravel.log

app/Auth/Access/SocialAuthService.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use BookStack\Exceptions\SocialDriverNotConfigured;
66
use BookStack\Exceptions\SocialSignInAccountNotUsed;
77
use BookStack\Exceptions\UserRegistrationException;
8+
use Illuminate\Support\Str;
89
use Laravel\Socialite\Contracts\Factory as Socialite;
910
use Laravel\Socialite\Contracts\User as SocialUser;
1011

@@ -104,6 +105,7 @@ public function handleLoginCallback($socialDriver, SocialUser $socialUser)
104105
$socialAccount = $this->socialAccount->where('driver_id', '=', $socialId)->first();
105106
$isLoggedIn = auth()->check();
106107
$currentUser = user();
108+
$titleCaseDriver = Str::title($socialDriver);
107109

108110
// When a user is not logged in and a matching SocialAccount exists,
109111
// Simply log the user into the application.
@@ -117,26 +119,26 @@ public function handleLoginCallback($socialDriver, SocialUser $socialUser)
117119
if ($isLoggedIn && $socialAccount === null) {
118120
$this->fillSocialAccount($socialDriver, $socialUser);
119121
$currentUser->socialAccounts()->save($this->socialAccount);
120-
session()->flash('success', trans('settings.users_social_connected', ['socialAccount' => title_case($socialDriver)]));
122+
session()->flash('success', trans('settings.users_social_connected', ['socialAccount' => $titleCaseDriver]));
121123
return redirect($currentUser->getEditUrl());
122124
}
123125

124126
// When a user is logged in and the social account exists and is already linked to the current user.
125127
if ($isLoggedIn && $socialAccount !== null && $socialAccount->user->id === $currentUser->id) {
126-
session()->flash('error', trans('errors.social_account_existing', ['socialAccount' => title_case($socialDriver)]));
128+
session()->flash('error', trans('errors.social_account_existing', ['socialAccount' => $titleCaseDriver]));
127129
return redirect($currentUser->getEditUrl());
128130
}
129131

130132
// When a user is logged in, A social account exists but the users do not match.
131133
if ($isLoggedIn && $socialAccount !== null && $socialAccount->user->id != $currentUser->id) {
132-
session()->flash('error', trans('errors.social_account_already_used_existing', ['socialAccount' => title_case($socialDriver)]));
134+
session()->flash('error', trans('errors.social_account_already_used_existing', ['socialAccount' => $titleCaseDriver]));
133135
return redirect($currentUser->getEditUrl());
134136
}
135137

136138
// Otherwise let the user know this social account is not used by anyone.
137-
$message = trans('errors.social_account_not_used', ['socialAccount' => title_case($socialDriver)]);
139+
$message = trans('errors.social_account_not_used', ['socialAccount' => $titleCaseDriver]);
138140
if (setting('registration-enabled')) {
139-
$message .= trans('errors.social_account_register_instructions', ['socialAccount' => title_case($socialDriver)]);
141+
$message .= trans('errors.social_account_register_instructions', ['socialAccount' => $titleCaseDriver]);
140142
}
141143

142144
throw new SocialSignInAccountNotUsed($message, '/login');
@@ -157,7 +159,7 @@ private function validateDriver($socialDriver)
157159
abort(404, trans('errors.social_driver_not_found'));
158160
}
159161
if (!$this->checkDriverConfigured($driver)) {
160-
throw new SocialDriverNotConfigured(trans('errors.social_driver_not_configured', ['socialAccount' => title_case($socialDriver)]));
162+
throw new SocialDriverNotConfigured(trans('errors.social_driver_not_configured', ['socialAccount' => Str::title($socialDriver)]));
161163
}
162164

163165
return $driver;
@@ -244,7 +246,7 @@ public function fillSocialAccount($socialDriver, $socialUser)
244246
public function detachSocialAccount($socialDriver)
245247
{
246248
user()->socialAccounts()->where('driver', '=', $socialDriver)->delete();
247-
session()->flash('success', trans('settings.users_social_disconnected', ['socialAccount' => title_case($socialDriver)]));
249+
session()->flash('success', trans('settings.users_social_disconnected', ['socialAccount' => Str::title($socialDriver)]));
248250
return redirect(user()->getEditUrl());
249251
}
250252

app/Auth/Access/UserTokenService.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use BookStack\Exceptions\UserTokenNotFoundException;
66
use Carbon\Carbon;
77
use Illuminate\Database\Connection as Database;
8+
use Illuminate\Support\Str;
89
use stdClass;
910

1011
class UserTokenService
@@ -73,9 +74,9 @@ public function checkTokenAndGetUserId(string $token) : int
7374
*/
7475
protected function generateToken() : string
7576
{
76-
$token = str_random(24);
77+
$token = Str::random(24);
7778
while ($this->tokenExists($token)) {
78-
$token = str_random(25);
79+
$token = Str::random(25);
7980
}
8081
return $token;
8182
}

app/Auth/Permissions/PermissionsRepo.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use BookStack\Auth\Permissions;
44
use BookStack\Auth\Role;
55
use BookStack\Exceptions\PermissionsException;
6+
use Illuminate\Support\Str;
67

78
class PermissionsRepo
89
{
@@ -66,7 +67,7 @@ public function saveNewRole($roleData)
6667
$role->name = str_replace(' ', '-', strtolower($roleData['display_name']));
6768
// Prevent duplicate names
6869
while ($this->role->where('name', '=', $role->name)->count() > 0) {
69-
$role->name .= strtolower(str_random(2));
70+
$role->name .= strtolower(Str::random(2));
7071
}
7172
$role->save();
7273

app/Config/app.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136

137137
// Laravel
138138
'App' => Illuminate\Support\Facades\App::class,
139+
'Arr' => Illuminate\Support\Arr::class,
139140
'Artisan' => Illuminate\Support\Facades\Artisan::class,
140141
'Auth' => Illuminate\Support\Facades\Auth::class,
141142
'Blade' => Illuminate\Support\Facades\Blade::class,
@@ -165,6 +166,7 @@
165166
'Schema' => Illuminate\Support\Facades\Schema::class,
166167
'Session' => Illuminate\Support\Facades\Session::class,
167168
'Storage' => Illuminate\Support\Facades\Storage::class,
169+
'Str' => Illuminate\Support\Str::class,
168170
'URL' => Illuminate\Support\Facades\URL::class,
169171
'Validator' => Illuminate\Support\Facades\Validator::class,
170172
'View' => Illuminate\Support\Facades\View::class,

app/Config/auth.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
'api' => [
3737
'driver' => 'token',
3838
'provider' => 'users',
39+
'hash' => false,
3940
],
4041
],
4142

app/Config/broadcasting.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@
2424

2525
'pusher' => [
2626
'driver' => 'pusher',
27-
'key' => env('PUSHER_KEY'),
28-
'secret' => env('PUSHER_SECRET'),
27+
'key' => env('PUSHER_APP_KEY'),
28+
'secret' => env('PUSHER_APP_SECRET'),
2929
'app_id' => env('PUSHER_APP_ID'),
30+
'options' => [
31+
'cluster' => env('PUSHER_APP_CLUSTER'),
32+
'useTLS' => true,
33+
],
3034
],
3135

3236
'redis' => [
@@ -38,6 +42,11 @@
3842
'driver' => 'log',
3943
],
4044

45+
'null' => [
46+
'driver' => 'null',
47+
],
48+
49+
4150
],
4251

4352
];

app/Config/database.php

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,9 @@
5959
// Many of those shown here are unsupported by BookStack.
6060
'connections' => [
6161

62-
'sqlite' => [
63-
'driver' => 'sqlite',
64-
'database' => storage_path('database.sqlite'),
65-
'prefix' => '',
66-
],
67-
6862
'mysql' => [
6963
'driver' => 'mysql',
64+
'url' => env('DATABASE_URL'),
7065
'host' => $mysql_host,
7166
'database' => env('DB_DATABASE', 'forge'),
7267
'username' => env('DB_USERNAME', 'forge'),
@@ -79,10 +74,14 @@
7974
'prefix_indexes' => true,
8075
'strict' => false,
8176
'engine' => null,
77+
'options' => extension_loaded('pdo_mysql') ? array_filter([
78+
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
79+
]) : [],
8280
],
8381

8482
'mysql_testing' => [
8583
'driver' => 'mysql',
84+
'url' => env('TEST_DATABASE_URL'),
8685
'host' => '127.0.0.1',
8786
'database' => 'bookstack-test',
8887
'username' => env('MYSQL_USER', 'bookstack-test'),
@@ -94,27 +93,6 @@
9493
'strict' => false,
9594
],
9695

97-
'pgsql' => [
98-
'driver' => 'pgsql',
99-
'host' => env('DB_HOST', 'localhost'),
100-
'database' => env('DB_DATABASE', 'forge'),
101-
'username' => env('DB_USERNAME', 'forge'),
102-
'password' => env('DB_PASSWORD', ''),
103-
'charset' => 'utf8',
104-
'prefix' => '',
105-
'schema' => 'public',
106-
],
107-
108-
'sqlsrv' => [
109-
'driver' => 'sqlsrv',
110-
'host' => env('DB_HOST', 'localhost'),
111-
'database' => env('DB_DATABASE', 'forge'),
112-
'username' => env('DB_USERNAME', 'forge'),
113-
'password' => env('DB_PASSWORD', ''),
114-
'charset' => 'utf8',
115-
'prefix' => '',
116-
],
117-
11896
],
11997

12098
// Migration Repository Table

app/Config/queue.php

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// Queue connection configuration
1818
'connections' => [
1919

20+
2021
'sync' => [
2122
'driver' => 'sync',
2223
],
@@ -25,38 +26,15 @@
2526
'driver' => 'database',
2627
'table' => 'jobs',
2728
'queue' => 'default',
28-
'expire' => 60,
29-
],
30-
31-
'beanstalkd' => [
32-
'driver' => 'beanstalkd',
33-
'host' => 'localhost',
34-
'queue' => 'default',
35-
'ttr' => 60,
36-
],
37-
38-
'sqs' => [
39-
'driver' => 'sqs',
40-
'key' => 'your-public-key',
41-
'secret' => 'your-secret-key',
42-
'queue' => 'your-queue-url',
43-
'region' => 'us-east-1',
44-
],
45-
46-
'iron' => [
47-
'driver' => 'iron',
48-
'host' => 'mq-aws-us-east-1.iron.io',
49-
'token' => 'your-token',
50-
'project' => 'your-project-id',
51-
'queue' => 'your-queue-name',
52-
'encrypt' => true,
29+
'retry_after' => 90,
5330
],
5431

5532
'redis' => [
5633
'driver' => 'redis',
5734
'connection' => 'default',
58-
'queue' => 'default',
59-
'expire' => 60,
35+
'queue' => env('REDIS_QUEUE', 'default'),
36+
'retry_after' => 90,
37+
'block_for' => null,
6038
],
6139

6240
],

app/Config/services.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,6 @@
2222
// Callback URL for social authentication methods
2323
'callback_url' => env('APP_URL', false),
2424

25-
'mailgun' => [
26-
'domain' => '',
27-
'secret' => '',
28-
'endpoint' => '',
29-
],
30-
31-
'ses' => [
32-
'key' => '',
33-
'secret' => '',
34-
'region' => 'us-east-1',
35-
],
36-
37-
'stripe' => [
38-
'model' => \BookStack\Auth\User::class,
39-
'key' => '',
40-
'secret' => '',
41-
'webhook' => [
42-
'secret' => '',
43-
'tolerance' => 300,
44-
],
45-
],
46-
4725
'github' => [
4826
'client_id' => env('GITHUB_APP_ID', false),
4927
'client_secret' => env('GITHUB_APP_SECRET', false),

0 commit comments

Comments
 (0)