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

Call to a member function getClientOriginalExtension() on null #1570

Closed
TBK opened this issue Aug 1, 2019 · 2 comments
Closed

Call to a member function getClientOriginalExtension() on null #1570

TBK opened this issue Aug 1, 2019 · 2 comments
Milestone

Comments

@TBK
Copy link
Contributor

TBK commented Aug 1, 2019

Describe the bug
After one of the latest updates (not sure which), I can no longer create new Books or Shelves.

After enabling debugging (debugbar) I got the following:

/app/app/Providers/AppServiceProvider.php

    use Illuminate\Database\Eloquent\Relations\Relation;
    use Illuminate\Http\UploadedFile;
    use Illuminate\Support\Facades\View;
    use Illuminate\Support\ServiceProvider;
    use Schema;
    use Validator;
     
    class AppServiceProvider extends ServiceProvider
    {
        /**
         * Bootstrap any application services.
         *
         * @return void
         */
        public function boot()
        {
            // Custom validation methods
            Validator::extend('image_extension', function ($attribute, $value, $parameters, $validator) {
                $validImageExtensions = ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'tiff', 'webp'];
                return in_array(strtolower($value->getClientOriginalExtension()), $validImageExtensions);
            });
     
            Validator::extend('no_double_extension', function ($attribute, $value, $parameters, $validator) {
                $uploadName = $value->getClientOriginalName();
                return substr_count($uploadName, '.') < 2;
            });
     
            // Custom blade view directives
            Blade::directive('icon', function ($expression) {
                return "<?php echo icon($expression); ?>";
            });
     
            // Allow longer string lengths after upgrade to utf8mb4
            Schema::defaultStringLength(191);
     
            // Set morph-map due to namespace changes
            Relation::morphMap([
                'BookStack\\Bookshelf' => Bookshelf::class,
                'BookStack\\Book' => Book::class,
                'BookStack\\Chapter' => Chapter::class,

Arguments

    "Call to a member function getClientOriginalExtension() on null"

When feeding the form a Cover Image I get redirected to the frontpage and get the following debugbar exception:

The given data was invalid./app/vendor/laravel/framework/src/Illuminate/Validation/Validator.php#306

Steps To Reproduce
Steps to reproduce the behavior:

  1. Setup docker env + BookStack.
  2. Click "Create New Shelf" or "Create New Book"
  3. Fill in info and leave out adding a Cover Image
  4. See error

Expected behavior
To be able to create new Books/Shelves.

Your Configuration (please complete the following information):

Additional context
I am running an nontraditional php setup by using ppm https://github.com/php-pm/php-pm

@TBK TBK mentioned this issue Feb 15, 2020
@TBK
Copy link
Contributor Author

TBK commented Feb 15, 2020

hmm turns out that the issue is primarily related to mime/file validation rules which for some reason does not work. I still have to investigate if it is caused by the PHP version, Alpine or PPM.

@ssddanbrown ssddanbrown added this to the v0.28.3 milestone Mar 14, 2020
@ssddanbrown
Copy link
Member

I assume this issue was still linked to #1900, hence I'll close this off as that pull request has been merged into master for the next patch release. If that's not correct, just let me know.

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

No branches or pull requests

2 participants