Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Dont call filesystem delete with null #74

Merged
merged 1 commit into from Feb 17, 2022
Merged

[BUGFIX] Dont call filesystem delete with null #74

merged 1 commit into from Feb 17, 2022

Conversation

Woeler
Copy link
Contributor

@Woeler Woeler commented Feb 11, 2022

Applications using Laravel 9 will use FlySystem 3. The delete methods of FlySystem 3 no longer allow null as an argument. The argument must be a string.

See: https://github.com/thephpleague/flysystem/blob/3.x/src/Filesystem.php#L82

This pr simply surrounds the delete call with an if statement, so it isn't called when the given argument is null. This happens when using Laravel 9 while creating a new resource using the AdvancedImage field.

@sonarcloud
Copy link

sonarcloud bot commented Feb 11, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@Woeler Woeler changed the title [BUGFIX] Dont delete with null property when creating [BUGFIX] Dont call filesystem delete with null Feb 11, 2022
@Woeler
Copy link
Contributor Author

Woeler commented Feb 17, 2022

I am not sure if this is being maintained anymore. For those wanting a solution without editing the vendor code, create your own class that extends AdvancedImage and use it in instead. Class looks like this:

<?php

declare(strict_types=1);

namespace App\Nova\Fields;

use Laravel\Nova\Http\Requests\NovaRequest;

class AdvancedImage extends \Ctessier\NovaAdvancedImageField\AdvancedImage
{
    protected function fillAttribute(NovaRequest $request, $requestAttribute, $model, $attribute): void
    {
        $model->{$attribute} = $model->{$attribute} ?? '';

        parent::fillAttribute($request, $requestAttribute, $model, $attribute);
    }
}

@ctessier ctessier merged commit ce72ff6 into ctessier:1.x Feb 17, 2022
@ctessier
Copy link
Owner

Hi @Woeler !

Thank you very much for your contribution 🎉

The pull request was merged and I just released v1.3.1!

Hope you have a great day!
Clément

@Woeler
Copy link
Contributor Author

Woeler commented Feb 17, 2022

Thanks! Fantastic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants