Skip to content

Commit

Permalink
fix insert queries for mysql strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nosilver4u committed Apr 12, 2024
1 parent 4f8dd9d commit 307da35
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions classes/class-background-process-media.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ protected function queue_single_size( $id, $size, $file_path, $item ) {
$ewwwdb->ewwwio_images,
array(
'path' => \ewww_image_optimizer_relativize_path( $file_path ),
'converted' => '',
'gallery' => 'media',
'orig_size' => $image_size,
'attachment_id' => $id,
Expand Down
7 changes: 5 additions & 2 deletions common.php
Original file line number Diff line number Diff line change
Expand Up @@ -2590,6 +2590,7 @@ function ewww_image_optimizer_handle_upload( $params ) {
$ewwwdb->ewwwio_images,
array(
'path' => ewww_image_optimizer_relativize_path( $file_path ),
'converted' => '',
'orig_size' => $orig_size,
)
);
Expand Down Expand Up @@ -6247,6 +6248,7 @@ function ewww_image_optimizer_single_insert( $path, $gallery = '', $attachment_i
}
$to_insert = array(
'path' => $utf8_file_path,
'converted' => '',
'orig_size' => $orig_size,
'pending' => 1,
);
Expand Down Expand Up @@ -6468,10 +6470,9 @@ function ewww_image_optimizer_update_table( $attachment, $opt_size, $orig_size,
$converted = ewww_image_optimizer_relativize_path( $original );
} else {
$already_optimized = ewww_image_optimizer_find_already_optimized( $attachment );
$converted = '';
if ( is_array( $already_optimized ) && ! empty( $already_optimized['converted'] ) ) {
$converted = $already_optimized['converted'];
} else {
$converted = '';
}
}
if ( is_array( $already_optimized ) && ! empty( $already_optimized['updates'] ) && $opt_size >= $orig_size ) {
Expand Down Expand Up @@ -6605,6 +6606,7 @@ function ewww_image_optimizer_update_webp_results( $attachment, $webp_size, $web
// Store info on the current image for future reference.
if ( empty( $already_optimized ) || ! is_array( $already_optimized ) ) {
ewwwio_debug_message( "creating new record for $attachment" );
$updates['converted'] = '';
$ewwwdb->insert( $ewwwdb->ewwwio_images, $updates );
} else {
ewwwio_debug_message( "updating existing record ({$already_optimized['id']}), path: $attachment" );
Expand Down Expand Up @@ -6669,6 +6671,7 @@ function ewww_image_optimizer_update_resize_results( $attachment, $resized_width
// Store info on the current image for future reference.
if ( empty( $already_optimized ) || ! is_array( $already_optimized ) ) {
ewwwio_debug_message( "creating new record for $attachment" );
$updates['converted'] = '';
$ewwwdb->insert( $ewwwdb->ewwwio_images, $updates );
} else {
ewwwio_debug_message( "updating existing record ({$already_optimized['id']}), path: $attachment" );
Expand Down
2 changes: 2 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,13 @@ That's not a question, but since I made it up, I'll answer it. See this resource

= 7.5.1 =
*Release Date - TBD*

* added: Lazy Load can use dominant color placeholders via Easy IO
* added: ability to filter/parse admin-ajax.php requests via eio_filter_admin_ajax_response filter
* changed: improved smoothing of LQIP for Lazy Load when using Easy IO
* fixed: async bulk interface does not show Start Optimizing when image queue is already visible
* fixed: bulk process appears to have completed after clearing queue
* fixed: storing resize/webp results for new images fails with MySQL strict mode

= 7.5.0 =
*Release Date - March 26, 2024*
Expand Down
1 change: 1 addition & 0 deletions tests/test-tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ function test_ewwwio_images_table() {
unset( $record['id'] );
$record['image_size'] = $file_size;
$record['path'] = ewww_image_optimizer_relativize_path( $opt_file );
$record['converted'] = '';
$wpdb->insert( $wpdb->ewwwio_images, $record );
$record['image_size'] = 0;
$wpdb->insert( $wpdb->ewwwio_images, $record );
Expand Down

0 comments on commit 307da35

Please sign in to comment.