FriendsOfFlarum / upload

The file upload extension with insane intelligence for your Flarum forum.
https://discuss.flarum.org/d/4154
MIT License
176 stars 95 forks source link

Undefinied mimeTypes #254

Closed jbdesbas closed 3 years ago

jbdesbas commented 3 years ago

Hi,

It seem the system can't read the configured mimeType policy, so only the default behaviour is occuring (allow only image, write in local folder). Instead the maximum file size configuration is correctly applied.

Any idea ?

2021/01/06 15:46:51 [error] 1064#1064: *103 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined property: FoF\Upload\Helpers\Util::$mimeTypes in /opt/flarum/vendor/fof/upload/src/Helpers/Util.php on line 58" while reading response header from upstream, client: 192.168.1.53, server: , request: "POST /api/fof/upload HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm7.sock:", host: "192.168.1.13:5003", referrer: "http://192.168.1.13:5003/d/8-ddtgfdgd/3" 192.168.1.53 - -

I am using this install : https://github.com/crazy-max/docker-flarum

Regards,

andreas-hofmann commented 3 years ago

I'm having the same problem. Manually hardcoding some other mimetype into src/Helpers/Util.php:82 works, so I'm falling back to the default case specified in the code.

I just tried to reproduce the issue with a clean and fresh manual install in a container via composer, using Ubuntu 20.04 + Aapche2, following the installtion instructions.

Here's some info about the setup:

Flarum core 0.1.0-beta.15 PHP version: 7.4.3 Loaded extensions: Core, date, libxml, openssl, pcre, zlib, filter, hash, pcntl, Reflection, SPL, session, standard, sodium, mysqlnd, PDO, xml, calendar, ctype, curl, dom, mbstring, FFI, fileinfo, ftp, gd, gettext, iconv, json, exif, mysqli, pdo_mysql, Phar, posix, readline, shmop, SimpleXML, sockets, sysvmsg, sysvsem, sysvshm, tokenizer, xmlreader, xmlwriter, xsl, zip, Zend OPcache +----------------------+----------------+--------+ | Flarum Extensions | | | +----------------------+----------------+--------+ | ID | Version | Commit | +----------------------+----------------+--------+ | flarum-approval | v0.1.0-beta.15 | | | flarum-bbcode | v0.1.0-beta.15 | | | flarum-emoji | v0.1.0-beta.15 | | | flarum-lang-english | v0.1.0-beta.15 | | | flarum-flags | v0.1.0-beta.15 | | | flarum-likes | v0.1.0-beta.15 | | | flarum-lock | v0.1.0-beta.15 | | | flarum-markdown | v0.1.0-beta.15 | | | flarum-mentions | v0.1.0-beta.15 | | | flarum-statistics | v0.1.0-beta.15 | | | flarum-sticky | v0.1.0-beta.15 | | | flarum-subscriptions | v0.1.0-beta.15 | | | flarum-suspend | v0.1.0-beta.15 | | | flarum-tags | v0.1.0-beta.15 | | | fof-upload | 0.12.1 | | +----------------------+----------------+--------+ Base URL: http://10.0.3.129 Installation path: /var/www/html Debug mode: off

Steps to reproduce:

If I can provide more info, let me know.

andreas-hofmann commented 3 years ago

Btw, I'm getting the same error message in the log:

[Sun Jan 10 18:09:45.382814 2021] [php7:notice] [pid 305] [client 10.0.3.1:43384] PHP Notice: Undefined property: FoF\Upload\Helpers\Util::$mimeTypes in /var/www/html/vendor/fof/upload/src/Helpers/Util.php on line 58, referer: http://10.0.3.129/

andreas-hofmann commented 3 years ago

MimeType extraction from the DB breaks with commit c8a4a4399171019b5b5c21ed0bfc1206c785904f. It seems like the mimeTypes setting still relies on the settings methods, which were removed when changing the class from Settings to Util.