Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Tested with PHP 7.1.6, when uploading a picture against a user the following warning appears:
Warning: A non-numeric value encountered in user_validate_picture() (line 692 of modules/user/user.module).
A typecast should resolve this:
function user_validate_picture(&$form, &$form_state) {
// If required, validate the uploaded picture.
$validators = array(
'file_validate_is_image' => array(),
'file_validate_image_resolution' => array(variable_get('user_picture_dimensions', '85x85')),
- 'file_validate_size' => array(variable_get('user_picture_file_size', '30') * 1024),
+ 'file_validate_size' => array((int)variable_get('user_picture_file_size', '30') * 1024),
);
...
}
Comments
Comment #2
MustangGB CreditAttribution: MustangGB commentedComment #3
Ayesh CreditAttribution: Ayesh as a volunteer commentedPHP 7.1 upgrade notice: http://php.net/manual/en/migration71.other-changes.php#migration71.other....
To reproduce, open the Account settings form, clear the "Picture upload file size" configuration field, and submit. The form element's
element_validate_integer_positive
validation is not enforced for blank values.Attached patch.
Comment #4
MustangGB CreditAttribution: MustangGB commentedWe both agree, so that should be enough to RTBC.
Comment #5
Vj CreditAttribution: Vj as a volunteer commentedI have tested patch works fine with Drupal 7 & PHP 7.
Without patch gives warning.
After patch no warning.
Comment #6
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedThis looks good, since the variable is already required to be an integer anyway.
Technically the fact that this bug exists means we are missing some test coverage, but I don't think it's worth the effort or entirely fair to make this issue responsible for adding it. Better to just do the simple bug fix here.
Committed to 7.x - thanks!
Comment #9
webservant316 CreditAttribution: webservant316 commentedworks for me
Comment #10
webservant316 CreditAttribution: webservant316 commentedCan this patch be committed to core? It is not included with 7.60.