CodeSleeve / laravel-stapler

Stapler-based file upload package for the Laravel framework.
MIT License
556 stars 109 forks source link

get_class() expects parameter 1 to be object, null given #132

Open iredmedia opened 6 years ago

iredmedia commented 6 years ago

I'm getting this error in one of my environments but I can't figure out why. It doesn't fail on home/login, but my internal pages it does.

get_class() expects parameter 1 to be object, null given

Here is more of the stack!

in Attachment.php (line 388)
--
at HandleExceptions->handleError(2, 'get_class() expects parameter 1 to be object, null given', '/app/vendor/codesleeve/stapler/src/Attachment.php', 388, array())
at get_class(null)in Attachment.php (line 388)
at Attachment->getInstanceClass()in Stapler.php (line 177)
at Stapler::getS3ClientInstance(object(Attachment))in Storage.php (line 27)

Edit: If i change the env FILESYSTEM_DRIVER to filesystem from S3 it works fine.

lostincode commented 6 years ago

Most likely because one of your environments is PHP 7.2 and the other is not.

Note: Explicitly passing NULL as the object is no longer allowed as of PHP 7.2.0. The parameter is still optional and calling get_class() without a parameter from inside a class will work, but passing NULL now emits an E_WARNING notice.

http://php.net/manual/en/function.get-class.php

Looks like this package will need an update to support PHP 7.2 and up.

Alex-query commented 5 years ago

i found a bad decidion use @ before $this->hasAttachedFile in __construct // @$this->hasAttachedFile