Skip to content

Commit

Permalink
Merge branch 'master' into 1838
Browse files Browse the repository at this point in the history
  • Loading branch information
ildyria committed Jun 24, 2023
2 parents ce124e6 + 7103c0b commit 9b332ff
Show file tree
Hide file tree
Showing 115 changed files with 1,950 additions and 782 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ DB_PORT=
DB_USERNAME=
DB_PASSWORD=
DB_LOG_SQL=false
DB_LOG_SQL_EXPLAIN=false #only for MySQL

# List foreign keys in diagnostic page
DB_LIST_FOREIGN_KEYS=true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
coverage: none
- name: Install PHP-CS-Fixer
run: |
curl -L https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v3.16.0/php-cs-fixer.phar -o .github/build/php-cs-fixer
curl -L https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v3.18.0/php-cs-fixer.phar -o .github/build/php-cs-fixer
chmod a+x .github/build/php-cs-fixer
- name: Prepare Git User
run: |
Expand Down
5 changes: 5 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function (PhpCsFixer\Finder $finder, $dir) {
)->notName('*.blade.php');
$rules = [
'@Symfony' => true,
'nullable_type_declaration_for_default_null_value' => true,
'align_multiline_comment' => true,
'array_indentation' => true,
'backtick_to_shell_exec' => true,
Expand All @@ -38,6 +39,10 @@ function (PhpCsFixer\Finder $finder, $dir) {
'no_unneeded_control_parentheses' => [
'statements' => ['break', 'clone', 'continue', 'echo_print', 'switch_case', 'yield'],
],
'operator_linebreak' => [
'only_booleans' => true,
'position' => 'end'
],
];
$config = new PhpCsFixer\Config();

Expand Down
5 changes: 2 additions & 3 deletions app/Actions/Album/SetProtectionPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SetProtectionPolicy extends Action
public function do(BaseAlbum $album, AlbumProtectionPolicy $protectionPolicy, bool $shallSetPassword, ?string $password): void
{
$album->is_nsfw = $protectionPolicy->is_nsfw;
$active_permissions = $album->public_permissions;
$active_permissions = $album->public_permissions();

if (!$protectionPolicy->is_public) {
$active_permissions?->delete();
Expand Down Expand Up @@ -58,9 +58,8 @@ public function do(BaseAlbum $album, AlbumProtectionPolicy $protectionPolicy, bo
$active_permissions->password = null;
}
}
$album->public_permissions()->save($active_permissions);
$active_permissions->base_album_id = $album->id;
$active_permissions->save();
// $album->save();

// Reset permissions for photos
$album->photos()->update(['photos.is_public' => false]);
Expand Down
4 changes: 2 additions & 2 deletions app/Actions/Album/Unlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function __construct()
*/
public function do(BaseAlbum $album, string $password): void
{
if ($album->public_permissions !== null) {
$album_password = $album->public_permissions->password;
if ($album->public_permissions() !== null) {
$album_password = $album->public_permissions()->password;
if (
$album_password === null ||
$album_password === '' ||
Expand Down
4 changes: 2 additions & 2 deletions app/Actions/Albums/Top.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ public function get(): TopAlbumsResource
}

$tagAlbumQuery = $this->albumQueryPolicy
->applyVisibilityFilter(TagAlbum::query()->with(['owner']));
->applyVisibilityFilter(TagAlbum::query()->with(['access_permissions', 'owner']));
/** @var BaseCollection<TagAlbum> $tagAlbums */
$tagAlbums = (new SortingDecorator($tagAlbumQuery))
->orderBy($this->sorting->column, $this->sorting->order)
->get();

/** @var NsQueryBuilder $query */
$query = $this->albumQueryPolicy
->applyVisibilityFilter(Album::query()->with(['owner'])->whereIsRoot());
->applyVisibilityFilter(Album::query()->with(['access_permissions', 'owner'])->whereIsRoot());

$userID = Auth::id();
if ($userID !== null) {
Expand Down
4 changes: 2 additions & 2 deletions app/Actions/Diagnostics/Pipes/Checks/GDSupportCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public function handle(array &$data, \Closure $next): array
// @codeCoverageIgnoreEnd
}
if (
!$gdVersion['GIF Read Support']
|| !$gdVersion['GIF Create Support']
!$gdVersion['GIF Read Support'] ||
!$gdVersion['GIF Create Support']
) {
// @codeCoverageIgnoreStart
$data[] = 'Error: PHP gd extension without full gif support';
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Diagnostics/Pipes/Checks/IniSettingsCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function handle(array &$data, \Closure $next): array
if (!extension_loaded('imagick')) {
// @codeCoverageIgnoreStart
$data[] = 'Warning: Pictures that are rotated lose their metadata! Please install Imagick to avoid that.';
// @codeCoverageIgnoreEnd
// @codeCoverageIgnoreEnd
} else {
if (!isset($settings['imagick'])) {
// @codeCoverageIgnoreStart
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Diagnostics/Pipes/Infos/ExtensionsInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function handle(array &$data, \Closure $next): array
if (!isset($imagickVersion, $imagickVersion['versionNumber'])) {
// @codeCoverageIgnoreStart
$imagickVersion = '-';
// @codeCoverageIgnoreEnd
// @codeCoverageIgnoreEnd
} else {
$imagickVersion = $imagickVersion['versionNumber'];
}
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Diagnostics/Pipes/Infos/VersionInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function handle(array &$data, \Closure $next): array
$fileVersion->hydrate(false, false);

$lycheeInfoString = $fileVersion->getVersion()->toString();
// @codeCoverageIgnoreEnd
// @codeCoverageIgnoreEnd
} else {
$gitHubFunctions = resolve(GitHubVersion::class);
$gitHubFunctions->hydrate();
Expand Down
8 changes: 5 additions & 3 deletions app/Actions/Import/FromUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ public function do(array $urls, ?Album $album, int $intendedOwnerId): Collection
$path = parse_url($url, PHP_URL_PATH);
$extension = '.' . pathinfo($path, PATHINFO_EXTENSION);

// Validate photo extension even when `$create->add()` will do later.
// This prevents us from downloading unsupported files.
BaseMediaFile::assertIsSupportedOrAcceptedFileExtension($extension);
if ($extension !== '.') {
// Validate photo extension even when `$create->add()` will do later.
// This prevents us from downloading unsupported files.
BaseMediaFile::assertIsSupportedOrAcceptedFileExtension($extension);
}

// Download file
$downloadedFile = new DownloadedFile($url);
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/InstallUpdate/Pipes/ComposerCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function handle(array &$output, \Closure $next): array
chdir(base_path());
exec(sprintf('composer install %s--no-progress 2>&1', $noDev), $output);
chdir(base_path('public'));
// @codeCoverageIgnoreEnd
// @codeCoverageIgnoreEnd
} else {
$output[] = 'Composer update are always dangerous when automated.';
$output[] = 'So we did not execute it.';
Expand Down
6 changes: 3 additions & 3 deletions app/Actions/Settings/UpdateLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public function do(?string $username, string $password, string $oldPassword, str
throw new UnauthenticatedException('Previous password is invalid');
}

if ($username !== null
&& $username !== ''
&& Configs::getValueAsBool('allow_username_change')) {
if ($username !== null &&
$username !== '' &&
Configs::getValueAsBool('allow_username_change')) {
$this->updateUsername($user, $username, $ip);
}

Expand Down
Loading

0 comments on commit 9b332ff

Please sign in to comment.