From 4680f5c69666368ec68e8fd7dfdc992ff7ce9768 Mon Sep 17 00:00:00 2001 From: Sertii <36940685+Sreini@users.noreply.github.com> Date: Mon, 16 Feb 2026 07:34:38 +0100 Subject: [PATCH 1/4] release: 3.6.10 --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 565e7c67..aa6e9ea1 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://tinypng.com/ Tags: compress images, compression, image size, page speed, performance Requires at least: 4.0 Tested up to: 6.9 -Stable tag: 3.6.9 +Stable tag: 3.6.10 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html From 28ca2f5ca01aff20bf5ffa005053e96e01e57353 Mon Sep 17 00:00:00 2001 From: tijmen Date: Thu, 19 Feb 2026 14:59:11 +0100 Subject: [PATCH 2/4] Only clear logs when enabled and previously not enabled --- src/class-tiny-logger.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/class-tiny-logger.php b/src/class-tiny-logger.php index 2111d39f..6cc2d1ad 100644 --- a/src/class-tiny-logger.php +++ b/src/class-tiny-logger.php @@ -108,12 +108,19 @@ public function get_log_file_path() { /** * Triggered when log_enabled is saved * - set the setting on the instance - * - if turn on, clear the old logs + * - will clear logs when turned on + * + * Hooked to `pre_update_option_tinypng_logging_enabled` filter + * + * @return bool true if enabled */ public static function on_save_log_enabled( $log_enabled, $old, $option ) { $instance = self::get_instance(); - $instance->log_enabled = 'on' === $log_enabled; - if ( $instance->get_log_enabled() ) { + $was_enabled = 'on' === $old; + $is_now_enabled = 'on' === $log_enabled; + $instance->log_enabled = $is_now_enabled; + + if ( ! $was_enabled && $is_now_enabled ) { self::clear_logs(); } From 0b0203fdf185be3039c372d46849e2ba0bf695ae Mon Sep 17 00:00:00 2001 From: tijmen Date: Thu, 19 Feb 2026 17:13:38 +0100 Subject: [PATCH 3/4] Add tests for clear logs --- test/unit/TinyLoggerTest.php | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/test/unit/TinyLoggerTest.php b/test/unit/TinyLoggerTest.php index 7140c0e9..de809797 100644 --- a/test/unit/TinyLoggerTest.php +++ b/test/unit/TinyLoggerTest.php @@ -113,4 +113,42 @@ public function test_removes_full_log_and_creates_new() assertTrue(filesize($logger->get_log_file_path()) < 1048576, 'log file rotated and less than 1MB'); } + + public function test_clears_logs_when_turned_on() { + $log_dir_path = 'wp-content/uploads/tiny-compress-logs'; + vfsStream::newDirectory($log_dir_path)->at($this->vfs); + $log_dir = $this->vfs->getChild($log_dir_path); + vfsStream::newFile('tiny-compress.log') + ->withContent('Some existing log content') + ->at($log_dir); + + $logger = Tiny_Logger::get_instance(); + $log_path = $logger->get_log_file_path(); + + assertTrue(file_exists($log_path), 'log file should exist'); + + Tiny_Logger::on_save_log_enabled( 'on', 'off', null ); + + assertFalse( file_exists($log_path), 'log file should be deleted after turning on logging' ); + } + + public function test_keeps_logs_when_unchanged() { + $log_dir_path = 'wp-content/uploads/tiny-compress-logs'; + vfsStream::newDirectory($log_dir_path)->at($this->vfs); + $log_dir = $this->vfs->getChild($log_dir_path); + vfsStream::newFile('tiny-compress.log') + ->withContent('Some existing log content') + ->at($log_dir); + + $logger = Tiny_Logger::get_instance(); + $log_path = $logger->get_log_file_path(); + + assertTrue(file_exists($log_path), 'log file should exist'); + + Tiny_Logger::on_save_log_enabled( 'on', 'on', null ); + + assertTrue( file_exists($log_path), 'log file should be deleted after turning on logging' ); + + unlink($log_path); + } } From 788e83eec02d96fbe8f33fe46c5a898bd67a3e81 Mon Sep 17 00:00:00 2001 From: tijmen Date: Fri, 20 Feb 2026 09:11:08 +0100 Subject: [PATCH 4/4] rewrite test assertion message --- test/unit/TinyLoggerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/TinyLoggerTest.php b/test/unit/TinyLoggerTest.php index de809797..37721eb1 100644 --- a/test/unit/TinyLoggerTest.php +++ b/test/unit/TinyLoggerTest.php @@ -147,7 +147,7 @@ public function test_keeps_logs_when_unchanged() { Tiny_Logger::on_save_log_enabled( 'on', 'on', null ); - assertTrue( file_exists($log_path), 'log file should be deleted after turning on logging' ); + assertTrue( file_exists($log_path), 'log file should still exist when settings remain unchanged' ); unlink($log_path); }