humhub-contrib / gallery

7 stars 11 forks source link

Depreciation bug with PHP 8.1 #132

Closed marc-farre closed 9 months ago

marc-farre commented 9 months ago

From the log (not reproduced). Path: gallery/custom-gallery/upload

Seams to be a problem with hash_sha1 of the uploaded file.

Log:

yii\base\ErrorException: substr(): Passing null to parameter #1
($string) of type string is deprecated in
/var/www/humhub/protected/humhub/modules/file/models/File.php:279
Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleError(8192,
'substr(): Passi...', '/home/clients/a...', 279)
#1
/var/www/humhub/protected/humhub/modules/file/models/File.php(279):
substr(NULL, 0, 8)
#2
/var/www/humhub/protected/humhub/modules/file/models/File.php(257):
humhub\modules\file\models\File->getHash(8)
#3
/var/www/humhub/protected/humhub/modules/file/libs/FileHelper.php(145):
humhub\modules\file\models\File->getUrl()
#4
/var/www/humhub/protected/modules/gallery/controllers/CustomGalleryController.php(187):
humhub\modules\file\libs\FileHelper::getFileInfos(Object(humhub\modules\gallery\models\MediaUpload))
#5
/var/www/humhub/protected/modules/gallery/controllers/CustomGalleryController.php(171):
humhub\modules\gallery\controllers\CustomGalleryController->handleMediaUpload(Object(humhub\modules\gallery\models\CustomGallery),
Object(yii\web\UploadedFile))
#6 [internal function]:
humhub\modules\gallery\controllers\CustomGalleryController->actionUpload()
#7
/var/www/humhub/protected/vendor/yiisoft/yii2/base/InlineAction.php(57):
call_user_func_array(Array, Array)
#8
/var/www/humhub/protected/vendor/yiisoft/yii2/base/Controller.php(178):
yii\base\InlineAction->runWithParams(Array)
#9
/var/www/humhub/protected/vendor/yiisoft/yii2/base/Module.php(552):
yii\base\Controller->runAction('upload', Array)
#10
/var/www/humhub/protected/vendor/yiisoft/yii2/web/Application.php(103):
yii\base\Module->runAction('gallery/custom-...', Array)
#11
/var/www/humhub/protected/vendor/yiisoft/yii2/base/Application.php(384):
yii\web\Application->handleRequest(Object(humhub\components\Request))
#12
/var/www/humhub/index.php(25):
yii\base\Application->run()
#13 {main}
luke- commented 9 months ago

@yurabakhtin Can you please take a look into this?

yurabakhtin commented 9 months ago

@luke- @marc-farre I could reproduce the issue with uploading a file with wrong(not image) extension:

bug

after fix https://github.com/humhub-contrib/gallery/pull/133 the error will looks like this:

error-media-upload

marc-farre commented 9 months ago

@yurabakhtin thanks!