Skip to content

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

Closed
@TBK

Description

@TBK

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions