Skip to content

Commit

Permalink
Fixes #1950 : Do not enforce strict model when downloading (#1997)
Browse files Browse the repository at this point in the history
* Do not enforce strict more when downloading
* add explanations
  • Loading branch information
ildyria authored Sep 3, 2023
1 parent cc9a6d4 commit ed6e157
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/Actions/Album/Archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use App\Policies\AlbumPolicy;
use App\Policies\PhotoPolicy;
use App\SmartAlbums\BaseSmartAlbum;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Gate;
use Safe\Exceptions\InfoException;
Expand Down Expand Up @@ -49,6 +50,15 @@ class Archive extends Action
*/
public function do(Collection $albums): StreamedResponse
{
// Issue #1950: Setting Model::shouldBeStrict(); in /app/Providers/AppServiceProvider.php breaks recursive album download.
//
// From my understanding it is because when we query an album with it's relations (photos & children),
// the relations of the children are not populated.
// As a result, when we try to query the picture list of those, it breaks.
// In that specific case, it is better to simply disable Model::shouldBeStrict() and eat the recursive SQL queries:
// for this specific case we must allow lazy loading.
Model::shouldBeStrict(false);

$this->deflateLevel = Configs::getValueAsInt('zip_deflate_level');

$responseGenerator = function () use ($albums) {
Expand Down

0 comments on commit ed6e157

Please sign in to comment.