PHP: Addressed 8.4 deprecations within app itself
This commit is contained in:
parent
3b4d3430a5
commit
5508c171db
|
@ -54,7 +54,7 @@ class Ldap
|
||||||
*
|
*
|
||||||
* @return \LDAP\Result|array|false
|
* @return \LDAP\Result|array|false
|
||||||
*/
|
*/
|
||||||
public function search($ldapConnection, string $baseDn, string $filter, array $attributes = null)
|
public function search($ldapConnection, string $baseDn, string $filter, array $attributes = [])
|
||||||
{
|
{
|
||||||
return ldap_search($ldapConnection, $baseDn, $filter, $attributes);
|
return ldap_search($ldapConnection, $baseDn, $filter, $attributes);
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ class Ldap
|
||||||
*
|
*
|
||||||
* @return \LDAP\Result|array|false
|
* @return \LDAP\Result|array|false
|
||||||
*/
|
*/
|
||||||
public function read($ldapConnection, string $baseDn, string $filter, array $attributes = null)
|
public function read($ldapConnection, string $baseDn, string $filter, array $attributes = [])
|
||||||
{
|
{
|
||||||
return ldap_read($ldapConnection, $baseDn, $filter, $attributes);
|
return ldap_read($ldapConnection, $baseDn, $filter, $attributes);
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ class Ldap
|
||||||
*
|
*
|
||||||
* @param resource|\LDAP\Connection $ldapConnection
|
* @param resource|\LDAP\Connection $ldapConnection
|
||||||
*/
|
*/
|
||||||
public function searchAndGetEntries($ldapConnection, string $baseDn, string $filter, array $attributes = null): array|false
|
public function searchAndGetEntries($ldapConnection, string $baseDn, string $filter, array $attributes = []): array|false
|
||||||
{
|
{
|
||||||
$search = $this->search($ldapConnection, $baseDn, $filter, $attributes);
|
$search = $this->search($ldapConnection, $baseDn, $filter, $attributes);
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ class Ldap
|
||||||
*
|
*
|
||||||
* @param resource|\LDAP\Connection $ldapConnection
|
* @param resource|\LDAP\Connection $ldapConnection
|
||||||
*/
|
*/
|
||||||
public function bind($ldapConnection, string $bindRdn = null, string $bindPassword = null): bool
|
public function bind($ldapConnection, ?string $bindRdn = null, ?string $bindPassword = null): bool
|
||||||
{
|
{
|
||||||
return ldap_bind($ldapConnection, $bindRdn, $bindPassword);
|
return ldap_bind($ldapConnection, $bindRdn, $bindPassword);
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ class SocialDriverManager
|
||||||
string $driverName,
|
string $driverName,
|
||||||
array $config,
|
array $config,
|
||||||
string $socialiteHandler,
|
string $socialiteHandler,
|
||||||
callable $configureForRedirect = null
|
?callable $configureForRedirect = null
|
||||||
) {
|
) {
|
||||||
$this->validDrivers[] = $driverName;
|
$this->validDrivers[] = $driverName;
|
||||||
config()->set('services.' . $driverName, $config);
|
config()->set('services.' . $driverName, $config);
|
||||||
|
|
|
@ -43,9 +43,9 @@ function user(): User
|
||||||
* Check if the current user has a permission. If an ownable element
|
* Check if the current user has a permission. If an ownable element
|
||||||
* is passed in the jointPermissions are checked against that particular item.
|
* is passed in the jointPermissions are checked against that particular item.
|
||||||
*/
|
*/
|
||||||
function userCan(string $permission, Model $ownable = null): bool
|
function userCan(string $permission, ?Model $ownable = null): bool
|
||||||
{
|
{
|
||||||
if ($ownable === null) {
|
if (is_null($ownable)) {
|
||||||
return user()->can($permission);
|
return user()->can($permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ function userCanOnAny(string $action, string $entityClass = ''): bool
|
||||||
*
|
*
|
||||||
* @return mixed|SettingService
|
* @return mixed|SettingService
|
||||||
*/
|
*/
|
||||||
function setting(string $key = null, $default = null)
|
function setting(?string $key = null, mixed $default = null): mixed
|
||||||
{
|
{
|
||||||
$settingService = app()->make(SettingService::class);
|
$settingService = app()->make(SettingService::class);
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ class BookController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show the form for creating a new book.
|
* Show the form for creating a new book.
|
||||||
*/
|
*/
|
||||||
public function create(string $shelfSlug = null)
|
public function create(?string $shelfSlug = null)
|
||||||
{
|
{
|
||||||
$this->checkPermission('book-create-all');
|
$this->checkPermission('book-create-all');
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ class BookController extends Controller
|
||||||
* @throws ImageUploadException
|
* @throws ImageUploadException
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
public function store(Request $request, string $shelfSlug = null)
|
public function store(Request $request, ?string $shelfSlug = null)
|
||||||
{
|
{
|
||||||
$this->checkPermission('book-create-all');
|
$this->checkPermission('book-create-all');
|
||||||
$validated = $this->validate($request, [
|
$validated = $this->validate($request, [
|
||||||
|
|
|
@ -41,7 +41,7 @@ class PageController extends Controller
|
||||||
*
|
*
|
||||||
* @throws Throwable
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
public function create(string $bookSlug, string $chapterSlug = null)
|
public function create(string $bookSlug, ?string $chapterSlug = null)
|
||||||
{
|
{
|
||||||
if ($chapterSlug) {
|
if ($chapterSlug) {
|
||||||
$parent = $this->entityQueries->chapters->findVisibleBySlugsOrFail($bookSlug, $chapterSlug);
|
$parent = $this->entityQueries->chapters->findVisibleBySlugsOrFail($bookSlug, $chapterSlug);
|
||||||
|
@ -69,7 +69,7 @@ class PageController extends Controller
|
||||||
*
|
*
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
public function createAsGuest(Request $request, string $bookSlug, string $chapterSlug = null)
|
public function createAsGuest(Request $request, string $bookSlug, ?string $chapterSlug = null)
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'name' => ['required', 'string', 'max:255'],
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
|
|
@ -18,7 +18,7 @@ class QueryPopular
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run(int $count, int $page, array $filterModels = null): Collection
|
public function run(int $count, int $page, array $filterModels): Collection
|
||||||
{
|
{
|
||||||
$query = $this->permissions
|
$query = $this->permissions
|
||||||
->restrictEntityRelationQuery(View::query(), 'views', 'viewable_id', 'viewable_type')
|
->restrictEntityRelationQuery(View::query(), 'views', 'viewable_id', 'viewable_type')
|
||||||
|
@ -26,7 +26,7 @@ class QueryPopular
|
||||||
->groupBy('viewable_id', 'viewable_type')
|
->groupBy('viewable_id', 'viewable_type')
|
||||||
->orderBy('view_count', 'desc');
|
->orderBy('view_count', 'desc');
|
||||||
|
|
||||||
if ($filterModels) {
|
if (!empty($filterModels)) {
|
||||||
$query->whereIn('viewable_type', $this->entityProvider->getMorphClasses($filterModels));
|
$query->whereIn('viewable_type', $this->entityProvider->getMorphClasses($filterModels));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ class RevisionRepo
|
||||||
/**
|
/**
|
||||||
* Store a new revision in the system for the given page.
|
* Store a new revision in the system for the given page.
|
||||||
*/
|
*/
|
||||||
public function storeNewForPage(Page $page, string $summary = null): PageRevision
|
public function storeNewForPage(Page $page, ?string $summary = null): PageRevision
|
||||||
{
|
{
|
||||||
$revision = new PageRevision();
|
$revision = new PageRevision();
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ class ThemeService
|
||||||
/**
|
/**
|
||||||
* @see SocialDriverManager::addSocialDriver
|
* @see SocialDriverManager::addSocialDriver
|
||||||
*/
|
*/
|
||||||
public function addSocialDriver(string $driverName, array $config, string $socialiteHandler, callable $configureForRedirect = null): void
|
public function addSocialDriver(string $driverName, array $config, string $socialiteHandler, ?callable $configureForRedirect = null): void
|
||||||
{
|
{
|
||||||
$driverManager = app()->make(SocialDriverManager::class);
|
$driverManager = app()->make(SocialDriverManager::class);
|
||||||
$driverManager->addSocialDriver($driverName, $config, $socialiteHandler, $configureForRedirect);
|
$driverManager->addSocialDriver($driverName, $config, $socialiteHandler, $configureForRedirect);
|
||||||
|
|
|
@ -49,9 +49,9 @@ class ImageRepo
|
||||||
string $type,
|
string $type,
|
||||||
int $page = 0,
|
int $page = 0,
|
||||||
int $pageSize = 24,
|
int $pageSize = 24,
|
||||||
int $uploadedTo = null,
|
?int $uploadedTo = null,
|
||||||
string $search = null,
|
?string $search = null,
|
||||||
callable $whereClause = null
|
?callable $whereClause = null
|
||||||
): array {
|
): array {
|
||||||
$imageQuery = Image::query()->where('type', '=', strtolower($type));
|
$imageQuery = Image::query()->where('type', '=', strtolower($type));
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ class ImageRepo
|
||||||
$parentFilter = function (Builder $query) use ($filterType, $contextPage) {
|
$parentFilter = function (Builder $query) use ($filterType, $contextPage) {
|
||||||
if ($filterType === 'page') {
|
if ($filterType === 'page') {
|
||||||
$query->where('uploaded_to', '=', $contextPage->id);
|
$query->where('uploaded_to', '=', $contextPage->id);
|
||||||
} elseif ($filterType === 'book') {
|
} else if ($filterType === 'book') {
|
||||||
$validPageIds = $contextPage->book->pages()
|
$validPageIds = $contextPage->book->pages()
|
||||||
->scopes('visible')
|
->scopes('visible')
|
||||||
->pluck('id')
|
->pluck('id')
|
||||||
|
@ -109,8 +109,14 @@ class ImageRepo
|
||||||
*
|
*
|
||||||
* @throws ImageUploadException
|
* @throws ImageUploadException
|
||||||
*/
|
*/
|
||||||
public function saveNew(UploadedFile $uploadFile, string $type, int $uploadedTo = 0, int $resizeWidth = null, int $resizeHeight = null, bool $keepRatio = true): Image
|
public function saveNew(
|
||||||
{
|
UploadedFile $uploadFile,
|
||||||
|
string $type,
|
||||||
|
int $uploadedTo = 0,
|
||||||
|
?int $resizeWidth = null,
|
||||||
|
?int $resizeHeight = null,
|
||||||
|
bool $keepRatio = true
|
||||||
|
): Image {
|
||||||
$image = $this->imageService->saveNewFromUpload($uploadFile, $type, $uploadedTo, $resizeWidth, $resizeHeight, $keepRatio);
|
$image = $this->imageService->saveNewFromUpload($uploadFile, $type, $uploadedTo, $resizeWidth, $resizeHeight, $keepRatio);
|
||||||
|
|
||||||
if ($type !== 'system') {
|
if ($type !== 'system') {
|
||||||
|
@ -184,7 +190,7 @@ class ImageRepo
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function destroyImage(Image $image = null): void
|
public function destroyImage(?Image $image = null): void
|
||||||
{
|
{
|
||||||
if ($image) {
|
if ($image) {
|
||||||
$this->imageService->destroy($image);
|
$this->imageService->destroy($image);
|
||||||
|
|
|
@ -31,8 +31,8 @@ class ImageService
|
||||||
UploadedFile $uploadedFile,
|
UploadedFile $uploadedFile,
|
||||||
string $type,
|
string $type,
|
||||||
int $uploadedTo = 0,
|
int $uploadedTo = 0,
|
||||||
int $resizeWidth = null,
|
?int $resizeWidth = null,
|
||||||
int $resizeHeight = null,
|
?int $resizeHeight = null,
|
||||||
bool $keepRatio = true,
|
bool $keepRatio = true,
|
||||||
string $imageName = '',
|
string $imageName = '',
|
||||||
): Image {
|
): Image {
|
||||||
|
|
|
@ -33,7 +33,7 @@ class UserApiController extends ApiController
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function rules(int $userId = null): array
|
protected function rules(?int $userId = null): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'create' => [
|
'create' => [
|
||||||
|
@ -54,7 +54,7 @@ class UserApiController extends ApiController
|
||||||
'string',
|
'string',
|
||||||
'email',
|
'email',
|
||||||
'min:2',
|
'min:2',
|
||||||
(new Unique('users', 'email'))->ignore($userId ?? null),
|
(new Unique('users', 'email'))->ignore($userId),
|
||||||
],
|
],
|
||||||
'external_auth_id' => ['string'],
|
'external_auth_id' => ['string'],
|
||||||
'language' => ['string', 'max:15', 'alpha_dash'],
|
'language' => ['string', 'max:15', 'alpha_dash'],
|
||||||
|
|
|
@ -4,11 +4,16 @@ namespace BookStack\Util;
|
||||||
|
|
||||||
use BookStack\Exceptions\HttpFetchException;
|
use BookStack\Exceptions\HttpFetchException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate the host we're connecting to when making a server-side-request.
|
||||||
|
* Will use the given hosts config if given during construction otherwise
|
||||||
|
* will look to the app configured config.
|
||||||
|
*/
|
||||||
class SsrUrlValidator
|
class SsrUrlValidator
|
||||||
{
|
{
|
||||||
protected string $config;
|
protected string $config;
|
||||||
|
|
||||||
public function __construct(string $config = null)
|
public function __construct(?string $config = null)
|
||||||
{
|
{
|
||||||
$this->config = $config ?? config('app.ssr_hosts') ?? '';
|
$this->config = $config ?? config('app.ssr_hosts') ?? '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ This method allows you to register a custom social authentication driver within
|
||||||
- string $driverName
|
- string $driverName
|
||||||
- array $config
|
- array $config
|
||||||
- string $socialiteHandler
|
- string $socialiteHandler
|
||||||
|
- callable|null $configureForRedirect = null
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
|
|
|
@ -191,20 +191,20 @@ class PageEditorTest extends TestCase
|
||||||
{
|
{
|
||||||
$resp = $this->asAdmin()->get($this->page->getUrl('/edit'));
|
$resp = $this->asAdmin()->get($this->page->getUrl('/edit'));
|
||||||
$editLink = $this->page->getUrl('/edit') . '?editor=';
|
$editLink = $this->page->getUrl('/edit') . '?editor=';
|
||||||
$this->withHtml($resp)->assertElementContains("a[href=\"${editLink}markdown-clean\"]", '(Clean Content)');
|
$this->withHtml($resp)->assertElementContains("a[href=\"{$editLink}markdown-clean\"]", '(Clean Content)');
|
||||||
$this->withHtml($resp)->assertElementContains("a[href=\"${editLink}markdown-stable\"]", '(Stable Content)');
|
$this->withHtml($resp)->assertElementContains("a[href=\"{$editLink}markdown-stable\"]", '(Stable Content)');
|
||||||
$this->withHtml($resp)->assertElementContains("a[href=\"${editLink}wysiwyg2024\"]", '(In Alpha Testing)');
|
$this->withHtml($resp)->assertElementContains("a[href=\"{$editLink}wysiwyg2024\"]", '(In Alpha Testing)');
|
||||||
|
|
||||||
$resp = $this->asAdmin()->get($this->page->getUrl('/edit?editor=markdown-stable'));
|
$resp = $this->asAdmin()->get($this->page->getUrl('/edit?editor=markdown-stable'));
|
||||||
$editLink = $this->page->getUrl('/edit') . '?editor=';
|
$editLink = $this->page->getUrl('/edit') . '?editor=';
|
||||||
$this->withHtml($resp)->assertElementContains("a[href=\"${editLink}wysiwyg\"]", 'Switch to WYSIWYG Editor');
|
$this->withHtml($resp)->assertElementContains("a[href=\"{$editLink}wysiwyg\"]", 'Switch to WYSIWYG Editor');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_editor_type_switch_options_dont_show_if_without_change_editor_permissions()
|
public function test_editor_type_switch_options_dont_show_if_without_change_editor_permissions()
|
||||||
{
|
{
|
||||||
$resp = $this->asEditor()->get($this->page->getUrl('/edit'));
|
$resp = $this->asEditor()->get($this->page->getUrl('/edit'));
|
||||||
$editLink = $this->page->getUrl('/edit') . '?editor=';
|
$editLink = $this->page->getUrl('/edit') . '?editor=';
|
||||||
$this->withHtml($resp)->assertElementNotExists("a[href*=\"${editLink}\"]");
|
$this->withHtml($resp)->assertElementNotExists("a[href*=\"{$editLink}\"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_page_editor_type_switch_does_not_work_without_change_editor_permissions()
|
public function test_page_editor_type_switch_does_not_work_without_change_editor_permissions()
|
||||||
|
|
Loading…
Reference in New Issue