Skip to content

Commit 35711c4

Browse files
3.6.4 Prevent items from being re-processed (#74)
* Prevent items from being re-processed * Remove unused var * v3.6.4
1 parent c6ad7ea commit 35711c4

5 files changed

Lines changed: 32 additions & 4 deletions

File tree

config/wpcli-dist.Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM wpcli/wp-cli:2-php8.2-alpine
2+
3+
RUN apk add --no-cache git zip unzip
4+
5+
RUN git config --global url."https://github.com/".insteadOf git@github.com: \
6+
&& git config --global url."https://".insteadOf git://
7+
8+
ENV WP_CLI_PACKAGES_DIR=/var/www/.wp-cli
9+
10+
RUN wp package install wp-cli/dist-archive-command:@stable
11+
12+
WORKDIR /var/www/html
13+
ENTRYPOINT ["wp"]

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Donate link: https://tinypng.com/
44
Tags: compress images, compression, image size, page speed, performance
55
Requires at least: 4.0
66
Tested up to: 6.8
7-
Stable tag: 3.6.3
7+
Stable tag: 3.6.4
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -174,6 +174,9 @@ A: You can upgrade to a paid account by adding your *Payment details* on your [a
174174
A: When the conversion feature is enabled (to convert images to AVIF or WebP), each image will use double the number of credits: one for compression and one for format conversion.
175175

176176
== Changelog ==
177+
= 3.6.4 =
178+
* added a guard to prevent bulk processing to requeue already processed images
179+
177180
= 3.6.3 =
178181
* Changed the source priority for picture elements
179182

src/class-tiny-plugin.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1919
*/
2020
class Tiny_Plugin extends Tiny_WP_Base {
21-
const VERSION = '3.6.3';
21+
const VERSION = '3.6.4';
2222
const MEDIA_COLUMN = self::NAME;
2323
const DATETIME_FORMAT = 'Y-m-d G:i:s';
2424

@@ -252,6 +252,7 @@ public function enqueue_scripts( $hook ) {
252252
'pluginVersion' => self::version(),
253253
'L10nAllDone' => __( 'All images are processed', 'tiny-compress-images' ),
254254
'L10nNoActionTaken' => __( 'No action taken', 'tiny-compress-images' ),
255+
'L10nDuplicate' => __( 'Image was already processed', 'tiny-compress-images' ),
255256
'L10nBulkAction' => __( 'Compress Images', 'tiny-compress-images' ),
256257
'L10nBulkMarkCompressed' => __( 'Mark as Compressed', 'tiny-compress-images' ),
257258
'L10nCancelled' => __( 'Cancelled', 'tiny-compress-images' ),

src/js/bulk-optimization.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
(function() {
2+
const processedItems = [];
23
var parallelCompressions = 5;
34

45
function updateProgressBar(successFullCompressions) {
@@ -148,6 +149,14 @@
148149
return;
149150
}
150151

152+
const itemID = items[i].ID;
153+
if (processedItems.includes(itemID)) {
154+
const row = jQuery('#optimization-items tr').eq(parseInt(i, 10) + 1);
155+
row.find('.status')
156+
.attr('data-status', 'skipped-duplicate')
157+
.html('<span class="icon dashicons dashicons-no alert"></span>' + tinyCompress.L10nDuplicate);
158+
}
159+
151160
var row = jQuery('#optimization-items tr').eq(parseInt(i, 10)+1);
152161
row.find('.status').removeClass('todo');
153162
row.find('.status').html('<span class="icon spinner"></span>' + tinyCompress.L10nCompressing).attr('data-status', 'compressing');
@@ -158,12 +167,13 @@
158167
data: {
159168
_nonce: tinyCompress.nonce,
160169
action: 'tiny_compress_image_for_bulk',
161-
id: items[i].ID,
170+
id: itemID,
162171
current_size: window.currentLibraryBytes
163172
},
164173
success: function(data) { bulkOptimizationCallback(null, data, items, i); },
165174
error: function(xhr, textStatus, errorThrown) { bulkOptimizationCallback(errorThrown, null, items, i, parallelCompressions); }
166175
});
176+
processedItems.push(itemID);
167177
jQuery('#tiny-progress span').html(i + 1);
168178
}
169179

@@ -176,6 +186,7 @@
176186
window.optimizationCancelled = false;
177187
window.totalRowsDrawn = 0;
178188
window.currentLibraryBytes = parseInt(jQuery('#optimized-library-size').data('bytes'), 10);
189+
processedItems.splice(0, processedItems.length);
179190

180191
jQuery('div.progress').css('animation', 'progress-bar 80s linear infinite');
181192
jQuery('div#optimization-spinner').css('display', 'inline-block');

tiny-compress-images.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Plugin Name: TinyPNG - JPEG, PNG & WebP image compression
44
* Description: Speed up your website. Optimize your JPEG, PNG, and WebP images automatically with TinyPNG.
5-
* Version: 3.6.3
5+
* Version: 3.6.4
66
* Author: TinyPNG
77
* Author URI: https://tinypng.com
88
* Text Domain: tiny-compress-images

0 commit comments

Comments
 (0)