File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,9 @@ public function new_like( WP_REST_Request $request ) {
73
73
$ comment_id = $ request ->get_param ( 'comment_id ' );
74
74
$ blog_id = \Jetpack_Options::get_option ( 'id ' );
75
75
76
+ $ cache_key = WPCom_Comments_Likes::get_cache_key ( $ comment_id , get_current_user_id () );
77
+ delete_transient ( $ cache_key );
78
+
76
79
// Call WPCom remote API to record a new like.
77
80
$ response = \Automattic \Jetpack \Connection \Client::wpcom_json_api_request_as_user (
78
81
"/sites/ $ blog_id/comments/ $ comment_id/likes/new " ,
@@ -96,6 +99,9 @@ public function delete_like( WP_REST_Request $request ) {
96
99
$ comment_id = $ request ->get_param ( 'comment_id ' );
97
100
$ blog_id = \Jetpack_Options::get_option ( 'id ' );
98
101
102
+ $ cache_key = WPCom_Comments_Likes::get_cache_key ( $ comment_id , get_current_user_id () );
103
+ delete_transient ( $ cache_key );
104
+
99
105
// Call WPCom remote API to delete the current user's like.
100
106
$ response = \Automattic \Jetpack \Connection \Client::wpcom_json_api_request_as_user (
101
107
"/sites/ $ blog_id/comments/ $ comment_id/likes/mine/delete " ,
Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ private function is_comment_likes_enabled() {
94
94
* @param int $user_id The user ID.
95
95
* @return string The cache key.
96
96
*/
97
- private function get_cache_key ( $ comment_id , $ user_id ) {
97
+ public static function get_cache_key ( $ comment_id , $ user_id ) {
98
98
return "comment_like_ {$ comment_id }_ {$ user_id }" ;
99
99
}
100
100
@@ -107,7 +107,7 @@ private function get_cache_key( $comment_id, $user_id ) {
107
107
* @return bool|WP_Error True if the comment is liked, false otherwise, or a WP_Error if the request fails.
108
108
*/
109
109
private function do_comment_like_api_request ( $ blog_id , $ user_id , $ comment_id ) {
110
- $ cache_key = $ this -> get_cache_key ( $ comment_id , $ user_id );
110
+ $ cache_key = self :: get_cache_key ( $ comment_id , $ user_id );
111
111
112
112
$ cached_result = get_transient ( $ cache_key );
113
113
You can’t perform that action at this time.
0 commit comments