Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php 8.1 warning #26

Open
Pok4 opened this issue Apr 12, 2022 · 5 comments
Open

php 8.1 warning #26

Pok4 opened this issue Apr 12, 2022 · 5 comments

Comments

@Pok4
Copy link

Pok4 commented Apr 12, 2022

[phpBB Debug] PHP Warning: in file C:/xampp2/htdocs/App/Entity/Uploader.php on line 202: Trying to access array offset on value of type int

 
On line 202 i have:
if($options['maxSize'] && $file['size'][0] > $options['maxSize']) $errors[] = $this->error_messages['max_file_size'];
when i cjhange $file['size'][0] to @$file['size'][0] the warning disappear.

Can someone test it on php 8.1 and fix this... ?

@Pok4
Copy link
Author

Pok4 commented Apr 12, 2022

i fixed by myself, change line to:
if($options['maxSize'] && isset($file['size'][0]) && $file['size'][0] > $options['maxSize']) $errors[] = $this->error_messages['max_file_size'];

@lenamtl
Copy link

lenamtl commented May 31, 2022

Hi,

Unfortunately this is not a fix, in fact It won't check the size correctly on server side.
This code will remove the warning but will not check the size server side...

So this bug should reopened...

@Pok4 Pok4 reopened this May 31, 2022
@Pok4
Copy link
Author

Pok4 commented May 31, 2022

We waiting :)

@lenamtl
Copy link

lenamtl commented Jun 1, 2022

Hi,

Here is the fix

$file['size'][0] should be replaced by $file['size']

Replace
if($options['maxSize'] && $file['size'][0] > $options['maxSize']) $errors[] = $this->error_messages['max_file_size'];

By
if($options['maxSize'] && $file['size'] > $options['maxSize']) $errors[] = $this->error_messages['max_file_size'];

Important:
I found another error when I compared the $options['maxSize'] VS $file['size'] they use different size format so they cannot be compared

So you need to edit
maxSize must be set in bytes not megabytes (because the code does not have any conversion)
You need to change the value in Javascript and in PHP.

@lenamtl
Copy link

lenamtl commented Jun 2, 2022

This bug can be closes now ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants