From 0c5700d4f174d1e2f7de0082b7ea7d34ec5da169 Mon Sep 17 00:00:00 2001 From: datorik Date: Thu, 16 Apr 2026 20:25:50 +0300 Subject: [PATCH 1/2] Fix. Psalm error fix --- cleantalk.php | 6 +++--- lib/Cleantalk/ApbctWP/FindSpam/ListTable/BadUsers.php | 2 +- lib/Cleantalk/ApbctWP/FindSpam/ListTable/CommentsScan.php | 2 +- lib/Cleantalk/ApbctWP/FindSpam/ListTable/UsersScan.php | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cleantalk.php b/cleantalk.php index d1189b66c..d8966e367 100644 --- a/cleantalk.php +++ b/cleantalk.php @@ -2136,7 +2136,7 @@ function apbct_rc__install_plugin($_wp = null, $plugin = null) die( 'FAIL ' . json_encode(array( 'error' => 'FAIL_TO_GET_LATEST_VERSION', - 'details' => $result instanceof WP_Error ? $result->get_error_message() : '', + 'details' => $result->get_error_message() ? $result->get_error_message() : '', )) ); } @@ -2173,7 +2173,7 @@ function apbct_rc__activate_plugin($plugin) $error_msg = ''; if (!$result || is_wp_error($result)) { - if ($result instanceof WP_Error) { + if ($result->get_error_message()) { $error_msg = ' ' . $result->get_error_message(); } $result_array = array( @@ -2293,7 +2293,7 @@ function apbct_rc__uninstall_plugin($plugin = null) $error_msg = ''; if (!$result || is_wp_error($result)) { - if ($result instanceof WP_Error) { + if (is_wp_error($result) && $result->get_error_message()) { $error_msg = ' ' . $result->get_error_message(); } $die_string = 'FAIL ' . json_encode(array( diff --git a/lib/Cleantalk/ApbctWP/FindSpam/ListTable/BadUsers.php b/lib/Cleantalk/ApbctWP/FindSpam/ListTable/BadUsers.php index d0df4ba2e..7d077eecb 100644 --- a/lib/Cleantalk/ApbctWP/FindSpam/ListTable/BadUsers.php +++ b/lib/Cleantalk/ApbctWP/FindSpam/ListTable/BadUsers.php @@ -21,7 +21,7 @@ public function prepare_items() // phpcs:ignore PSR1.Methods.CamelCapsMethodNam $current_screen = get_current_screen(); $per_page_option = !is_null($current_screen) - ? $current_screen->get_option('per_page', 'option') + ? (string) $current_screen->get_option('per_page', 'option') : '10'; $per_page = get_user_meta(get_current_user_id(), $per_page_option, true); if ( ! $per_page ) { diff --git a/lib/Cleantalk/ApbctWP/FindSpam/ListTable/CommentsScan.php b/lib/Cleantalk/ApbctWP/FindSpam/ListTable/CommentsScan.php index 43b4bd331..5ae52b924 100644 --- a/lib/Cleantalk/ApbctWP/FindSpam/ListTable/CommentsScan.php +++ b/lib/Cleantalk/ApbctWP/FindSpam/ListTable/CommentsScan.php @@ -11,7 +11,7 @@ public function prepare_items() // phpcs:ignore PSR1.Methods.CamelCapsMethodName $current_screen = get_current_screen(); $per_page_option = !is_null($current_screen) - ? $current_screen->get_option('per_page', 'option') + ? (string) $current_screen->get_option('per_page', 'option') : '10'; $per_page = get_user_meta(get_current_user_id(), $per_page_option, true); if ( ! $per_page ) { diff --git a/lib/Cleantalk/ApbctWP/FindSpam/ListTable/UsersScan.php b/lib/Cleantalk/ApbctWP/FindSpam/ListTable/UsersScan.php index bab6dc762..969c413a4 100644 --- a/lib/Cleantalk/ApbctWP/FindSpam/ListTable/UsersScan.php +++ b/lib/Cleantalk/ApbctWP/FindSpam/ListTable/UsersScan.php @@ -10,7 +10,7 @@ public function prepare_items() // phpcs:ignore PSR1.Methods.CamelCapsMethodName { $current_screen = get_current_screen(); $per_page_option = !is_null($current_screen) - ? $current_screen->get_option('per_page', 'option') + ? (string) $current_screen->get_option('per_page', 'option') : '10'; $per_page = get_user_meta(get_current_user_id(), $per_page_option, true); if ( ! $per_page ) { From 81cc05ecb9a20f60480d3c31769bb20e4c825b49 Mon Sep 17 00:00:00 2001 From: datorik Date: Fri, 17 Apr 2026 15:50:21 +0300 Subject: [PATCH 2/2] Fix. Psalm error fix --- cleantalk.php | 7 ++----- lib/Cleantalk/ApbctWP/FindSpam/ListTable/BadUsers.php | 2 +- lib/Cleantalk/ApbctWP/FindSpam/ListTable/CommentsScan.php | 2 +- lib/Cleantalk/ApbctWP/FindSpam/ListTable/UsersScan.php | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/cleantalk.php b/cleantalk.php index d8966e367..fae308ceb 100644 --- a/cleantalk.php +++ b/cleantalk.php @@ -2136,7 +2136,7 @@ function apbct_rc__install_plugin($_wp = null, $plugin = null) die( 'FAIL ' . json_encode(array( 'error' => 'FAIL_TO_GET_LATEST_VERSION', - 'details' => $result->get_error_message() ? $result->get_error_message() : '', + 'details' => $result->get_error_message(), )) ); } @@ -2170,12 +2170,9 @@ function apbct_rc__activate_plugin($plugin) $result = activate_plugins($plugin); $result_array = array('success' => true); - $error_msg = ''; if (!$result || is_wp_error($result)) { - if ($result->get_error_message()) { - $error_msg = ' ' . $result->get_error_message(); - } + $error_msg = ' ' . $result->get_error_message(); $result_array = array( 'error' => 'FAIL_TO_ACTIVATE', 'details' => $error_msg diff --git a/lib/Cleantalk/ApbctWP/FindSpam/ListTable/BadUsers.php b/lib/Cleantalk/ApbctWP/FindSpam/ListTable/BadUsers.php index 7d077eecb..035f950a7 100644 --- a/lib/Cleantalk/ApbctWP/FindSpam/ListTable/BadUsers.php +++ b/lib/Cleantalk/ApbctWP/FindSpam/ListTable/BadUsers.php @@ -21,7 +21,7 @@ public function prepare_items() // phpcs:ignore PSR1.Methods.CamelCapsMethodNam $current_screen = get_current_screen(); $per_page_option = !is_null($current_screen) - ? (string) $current_screen->get_option('per_page', 'option') + ? ($current_screen->get_option('per_page', 'option') ?? '10') : '10'; $per_page = get_user_meta(get_current_user_id(), $per_page_option, true); if ( ! $per_page ) { diff --git a/lib/Cleantalk/ApbctWP/FindSpam/ListTable/CommentsScan.php b/lib/Cleantalk/ApbctWP/FindSpam/ListTable/CommentsScan.php index 5ae52b924..6350acac4 100644 --- a/lib/Cleantalk/ApbctWP/FindSpam/ListTable/CommentsScan.php +++ b/lib/Cleantalk/ApbctWP/FindSpam/ListTable/CommentsScan.php @@ -11,7 +11,7 @@ public function prepare_items() // phpcs:ignore PSR1.Methods.CamelCapsMethodName $current_screen = get_current_screen(); $per_page_option = !is_null($current_screen) - ? (string) $current_screen->get_option('per_page', 'option') + ? ($current_screen->get_option('per_page', 'option') ?? '10') : '10'; $per_page = get_user_meta(get_current_user_id(), $per_page_option, true); if ( ! $per_page ) { diff --git a/lib/Cleantalk/ApbctWP/FindSpam/ListTable/UsersScan.php b/lib/Cleantalk/ApbctWP/FindSpam/ListTable/UsersScan.php index 969c413a4..36d60fa86 100644 --- a/lib/Cleantalk/ApbctWP/FindSpam/ListTable/UsersScan.php +++ b/lib/Cleantalk/ApbctWP/FindSpam/ListTable/UsersScan.php @@ -10,7 +10,7 @@ public function prepare_items() // phpcs:ignore PSR1.Methods.CamelCapsMethodName { $current_screen = get_current_screen(); $per_page_option = !is_null($current_screen) - ? (string) $current_screen->get_option('per_page', 'option') + ? ($current_screen->get_option('per_page', 'option') ?? '10') : '10'; $per_page = get_user_meta(get_current_user_id(), $per_page_option, true); if ( ! $per_page ) {