WordPress/wordpress-playground

`$_FILES[...]['error']` should be `int` and not `string`

Closed this issue · 1 comments

In my plugin, I'm using UPLOAD_ERR_OK !== $_FILES['form-field-name']['error'] to check for issues with file uploads (from an <input type="file" name="form-field-name" /> in this example).

The UPLOAD_ERR_OK constant in PHP normally is an int, see https://3v4l.org/WjW2j .

However, in WordPress Playground, $_FILES['form-field-name']['error'] returns a string.

Maybe something in

// Set $_FILES['key']['error']
needs to be adjusted?

Good find @TobiasBg! It sounds like php_register_variable_ex would be a better choice as it accepts a zval instead of a char. This is what PHP does (through a few layers of indirection):

https://github.com/php/php-src/blob/d7d0d19d3279c040b852b7b8c3c38083cd29e4fd/main/rfc1867.c#L1232C5-L1232C41