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

Closed
opened 2026-02-05 00:30:53 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @TBK on GitHub (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

Originally created by @TBK on GitHub (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):** - Exact BookStack Version (Found in settings): 0.26.3 - PHP Version: 7.3.7 - Hosting Method (Nginx/Apache/Docker): Docker (custom image/setup - https://github.com/JJTC-Docker/bookstack-ppm) **Additional context** I am running an nontraditional php setup by using ppm https://github.com/php-pm/php-pm
Author
Owner

@TBK commented on GitHub (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.

@TBK commented on GitHub (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.
Author
Owner

@ssddanbrown commented on GitHub (Mar 14, 2020):

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.

@ssddanbrown commented on GitHub (Mar 14, 2020): 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 in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#1291