lonepress
Chevereto Member
This happens when images are updated via the json route with action=edit. For example, when using the "flag as unsafe" image overlay button.
The code calls Image::update(...), which calls G\nullify_string(...) on 'description' and 'category_id'. It looks like this call happens so that empty strings will be updated to null values in the database.
The problem is, if the $values array does not contain 'description' or 'category', this function adds them to the array with a null value, so the old values get erased.
I fixed it in Image::update by replacing this:
with this:
The code calls Image::update(...), which calls G\nullify_string(...) on 'description' and 'category_id'. It looks like this call happens so that empty strings will be updated to null values in the database.
The problem is, if the $values array does not contain 'description' or 'category', this function adds them to the array with a null value, so the old values get erased.
I fixed it in Image::update by replacing this:
PHP:
foreach(['description', 'category_id'] as $v) {
G\nullify_string($values[$v]);
}
PHP:
foreach(['description', 'category_id'] as $v) {
if (array_key_exists($v, $values)) {
G\nullify_string($values[$v]);
}
}