Skip to content

Commit

Permalink
Merge branch 'development' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
ssddanbrown committed Sep 20, 2022
2 parents 2ac9efa + aec772c commit 80374ae
Show file tree
Hide file tree
Showing 82 changed files with 585 additions and 446 deletions.
8 changes: 7 additions & 1 deletion .github/translators.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Alexander Predl (Harveyhase68) :: German
Rem (Rem9000) :: Dutch
Michał Stelmach (stelmach-web) :: Polish
arniom :: French
REMOVED_USER :: Dutch; Turkish
REMOVED_USER :: ; Dutch; Turkish
林祖年 (contagion) :: Chinese Traditional
Siamak Guodarzi (siamakgoudarzi88) :: Persian
Lis Maestrelo (lismtrl) :: Portuguese, Brazilian
Expand Down Expand Up @@ -274,3 +274,9 @@ Mihai Ochian (soulstorm19) :: Romanian
HeartCore :: German Informal; German
simon.pct :: French
okaeiz :: Persian
Naoto Ishikawa (na3shkw) :: Japanese
sdhadi :: Persian
DerLinkman (derlinkman) :: German; German Informal
TurnArabic :: Arabic
Martin Sebek (sebekmartin) :: Czech
Kuchinashi Hoshikawa (kuchinashi) :: Chinese Simplified
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
name: phpstan
name: analyse-php

on: [push, pull_request]

jobs:
build:
if: ${{ github.ref != 'refs/heads/l10n_development' }}
runs-on: ubuntu-20.04
strategy:
matrix:
php: ['7.4']
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v1

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
php-version: 8.1
extensions: gd, mbstring, json, curl, xml, mysql, ldap

- name: Get Composer Cache Directory
Expand All @@ -24,13 +21,14 @@ jobs:
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer packages
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php }}
key: ${{ runner.os }}-composer-8.1
restore-keys: ${{ runner.os }}-composer-

- name: Install composer dependencies
run: composer install --prefer-dist --no-interaction --ansi

- name: Run PHPStan
run: php${{ matrix.php }} ./vendor/bin/phpstan analyse --memory-limit=2G
- name: Run static analysis check
run: composer check-static
19 changes: 19 additions & 0 deletions .github/workflows/lint-php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: lint-php

on: [push, pull_request]

jobs:
build:
if: ${{ github.ref != 'refs/heads/l10n_development' }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v1

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
tools: phpcs

- name: Run formatting check
run: composer lint
5 changes: 3 additions & 2 deletions .github/workflows/test-migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: [push, pull_request]
jobs:
build:
if: ${{ github.ref != 'refs/heads/l10n_development' }}
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
php: ['7.4', '8.0', '8.1']
Expand All @@ -24,10 +24,11 @@ jobs:
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer packages
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php }}
restore-keys: ${{ runner.os }}-composer-

- name: Start MySQL
run: |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: phpunit
name: test-php

on: [push, pull_request]

jobs:
build:
if: ${{ github.ref != 'refs/heads/l10n_development' }}
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
php: ['7.4', '8.0', '8.1']
Expand All @@ -24,10 +24,11 @@ jobs:
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer packages
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php }}
restore-keys: ${{ runner.os }}-composer-

- name: Start Database
run: |
Expand All @@ -48,5 +49,5 @@ jobs:
php${{ matrix.php }} artisan migrate --force -n --database=mysql_testing
php${{ matrix.php }} artisan db:seed --force -n --class=DummyContentSeeder --database=mysql_testing
- name: phpunit
- name: Run PHP tests
run: php${{ matrix.php }} ./vendor/bin/phpunit
4 changes: 2 additions & 2 deletions app/Actions/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
*/
class Webhook extends Model implements Loggable
{
protected $fillable = ['name', 'endpoint', 'timeout'];

use HasFactory;

protected $fillable = ['name', 'endpoint', 'timeout'];

protected $casts = [
'last_called_at' => 'datetime',
'last_errored_at' => 'datetime',
Expand Down
4 changes: 2 additions & 2 deletions app/Actions/WebhookTrackedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
class WebhookTrackedEvent extends Model
{
protected $fillable = ['event'];

use HasFactory;

protected $fillable = ['event'];
}
2 changes: 1 addition & 1 deletion app/Auth/Access/LdapService.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function getUserDetails(string $userName): ?array
'name' => $this->getUserResponseProperty($user, $displayNameAttr, $userCn),
'dn' => $user['dn'],
'email' => $this->getUserResponseProperty($user, $emailAttr, null),
'avatar'=> $thumbnailAttr ? $this->getUserResponseProperty($user, $thumbnailAttr, null) : null,
'avatar' => $thumbnailAttr ? $this->getUserResponseProperty($user, $thumbnailAttr, null) : null,
];

if ($this->config['dump_user_details']) {
Expand Down
4 changes: 0 additions & 4 deletions app/Auth/Access/Oidc/OidcService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,18 @@

namespace BookStack\Auth\Access\Oidc;

use function auth;
use BookStack\Auth\Access\GroupSyncService;
use BookStack\Auth\Access\LoginService;
use BookStack\Auth\Access\RegistrationService;
use BookStack\Auth\User;
use BookStack\Exceptions\JsonDebugException;
use BookStack\Exceptions\StoppedAuthenticationException;
use BookStack\Exceptions\UserRegistrationException;
use function config;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Cache;
use League\OAuth2\Client\OptionProvider\HttpBasicAuthOptionProvider;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use Psr\Http\Client\ClientInterface as HttpClient;
use function trans;
use function url;

/**
* Class OpenIdConnectService
Expand Down
7 changes: 4 additions & 3 deletions app/Auth/Access/Saml2Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@ public function processAcsResponse(?string $requestId, string $samlResponse): ?U
$errors = $toolkit->getErrors();

if (!empty($errors)) {
throw new Error(
'Invalid ACS Response: ' . implode(', ', $errors)
);
$reason = $toolkit->getLastErrorReason();
$message = 'Invalid ACS Response; Errors: ' . implode(', ', $errors);
$message .= $reason ? "; Reason: {$reason}" : '';
throw new Error($message);
}

if (!$toolkit->isAuthenticated()) {
Expand Down
1 change: 1 addition & 0 deletions app/Config/dompdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Configuration should be altered via the `.env` file or environment variables.
* Do not edit this file unless you're happy to maintain any changes yourself.
*/

$dompdfPaperSizeMap = [
'a4' => 'a4',
'letter' => 'letter',
Expand Down
1 change: 1 addition & 0 deletions app/Config/snappy.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Configuration should be altered via the `.env` file or environment variables.
* Do not edit this file unless you're happy to maintain any changes yourself.
*/

$snappyPaperSizeMap = [
'a4' => 'A4',
'letter' => 'Letter',
Expand Down
2 changes: 1 addition & 1 deletion app/Entities/Tools/PageEditActivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function activeEditingMessage(): string
$userMessage = trans('entities.pages_draft_edit_active.start_b', ['userName' => $firstDraft->createdBy->name ?? '']);
}

$timeMessage = trans('entities.pages_draft_edit_active.time_b', ['minCount'=> 60]);
$timeMessage = trans('entities.pages_draft_edit_active.time_b', ['minCount' => 60]);

return trans('entities.pages_draft_edit_active.message', ['start' => $userMessage, 'time' => $timeMessage]);
}
Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/Auth/ForgotPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class ForgotPasswordController extends Controller
| your application to your users. Feel free to explore this trait.
|
*/

use SendsPasswordResetEmails;

/**
Expand Down
11 changes: 7 additions & 4 deletions app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ class LoginController extends Controller
| to conveniently provide its functionality to your applications.
|
*/

use AuthenticatesUsers { logout as traitLogout; }
use AuthenticatesUsers {
logout as traitLogout;
}

/**
* Redirection paths.
Expand Down Expand Up @@ -112,8 +113,10 @@ public function login(Request $request)
// If the class is using the ThrottlesLogins trait, we can automatically throttle
// the login attempts for this application. We'll key this by the username and
// the IP address of the client making these requests into this application.
if (method_exists($this, 'hasTooManyLoginAttempts') &&
$this->hasTooManyLoginAttempts($request)) {
if (
method_exists($this, 'hasTooManyLoginAttempts') &&
$this->hasTooManyLoginAttempts($request)
) {
$this->fireLockoutEvent($request);

Activity::logFailedLogin($username);
Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class RegisterController extends Controller
| provide this functionality without requiring any additional code.
|
*/

use RegistersUsers;

protected SocialAuthService $socialAuthService;
Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/Auth/ResetPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class ResetPasswordController extends Controller
| explore this trait and override any methods you wish to tweak.
|
*/

use ResetsPasswords;

protected $redirectTo = '/';
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/BookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function edit(string $slug)
{
$book = $this->bookRepo->getBySlug($slug);
$this->checkOwnablePermission('book-update', $book);
$this->setPageTitle(trans('entities.books_edit_named', ['bookName'=>$book->getShortName()]));
$this->setPageTitle(trans('entities.books_edit_named', ['bookName' => $book->getShortName()]));

return view('books.edit', ['book' => $book, 'current' => $book]);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/BookSortController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function show(string $bookSlug)

$bookChildren = (new BookContents($book))->getTree(false);

$this->setPageTitle(trans('entities.books_sort_named', ['bookName'=>$book->getShortName()]));
$this->setPageTitle(trans('entities.books_sort_named', ['bookName' => $book->getShortName()]));

return view('books.sort', ['book' => $book, 'current' => $book, 'bookChildren' => $bookChildren]);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/PageRevisionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function changes(string $bookSlug, string $pageSlug, int $revisionId)
// TODO - Refactor PageContent so we don't need to juggle this
$page->html = $revision->html;
$page->html = (new PageContent($page))->render();
$this->setPageTitle(trans('entities.pages_revision_named', ['pageName'=>$page->getShortName()]));
$this->setPageTitle(trans('entities.pages_revision_named', ['pageName' => $page->getShortName()]));

return view('pages.revision', [
'page' => $page,
Expand Down
2 changes: 1 addition & 1 deletion app/Uploads/ImageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ protected function resizeImage(string $imageData, ?int $width, ?int $height, boo
{
try {
$thumb = $this->imageTool->make($imageData);
} catch (ErrorException|NotSupportedException $e) {
} catch (ErrorException | NotSupportedException $e) {
throw new ImageUploadException(trans('errors.cannot_create_thumbs'));
}

Expand Down
4 changes: 3 additions & 1 deletion app/Util/LanguageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,14 @@ public function getIsoName(string $language): string
*/
public function setPhpDateTimeLocale(string $language): void
{
$isoLang = $this->localeMap[$language]['iso'] ?? false;
$isoLang = $this->localeMap[$language]['iso'] ?? '';
$isoLangPrefix = explode('_', $isoLang)[0];

$locales = array_filter([
$isoLang ? $isoLang . '.utf8' : false,
$isoLang ?: false,
$isoLang ? str_replace('_', '-', $isoLang) : false,
$isoLang ? $isoLangPrefix . '.UTF-8' : false,
$this->localeMap[$language]['windows'] ?? false,
$language,
]);
Expand Down
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"nunomaduro/collision": "^5.10",
"nunomaduro/larastan": "^1.0",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.7",
"ssddanbrown/asserthtml": "^1.0"
},
"autoload": {
Expand All @@ -68,6 +69,10 @@
}
},
"scripts": {
"check-static": "phpstan --memory-limit=2g",
"format": "phpcbf",
"lint": "phpcs",
"test": "phpunit",
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
Expand Down
Loading

0 comments on commit 80374ae

Please sign in to comment.