From 3b84996ba2c46a0d3057a6f214f2787c273464b4 Mon Sep 17 00:00:00 2001 From: Alex Cicovic <23142906+acicovic@users.noreply.github.com> Date: Wed, 21 May 2025 15:45:38 +0300 Subject: [PATCH 1/5] Make some caching checks more flexible --- src/Models/class-inbound-smart-link.php | 5 ++--- src/Models/class-smart-link.php | 8 ++++---- src/Utils/class-utils.php | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Models/class-inbound-smart-link.php b/src/Models/class-inbound-smart-link.php index 6aaeed898c..65982cb125 100644 --- a/src/Models/class-inbound-smart-link.php +++ b/src/Models/class-inbound-smart-link.php @@ -1069,9 +1069,8 @@ public static function get_suggestions_count( int $post_id ): int { $cache_key = self::get_suggestions_count_cache_key( $post_id ); $count = wp_cache_get( $cache_key, PARSELY_CACHE_GROUP ); - if ( false !== $count ) { - /** @var int $count */ - return $count; + if ( is_numeric( $count ) ) { + return (int) $count; } $args = array( diff --git a/src/Models/class-smart-link.php b/src/Models/class-smart-link.php index df48c2ac4d..a35e6c00dc 100644 --- a/src/Models/class-smart-link.php +++ b/src/Models/class-smart-link.php @@ -196,8 +196,9 @@ public function __construct( private function get_smart_link_object_by_uid( string $uid ): int { $cache_key = self::get_uid_to_smart_link_cache_key( $uid ); $cached = wp_cache_get( $cache_key, PARSELY_CACHE_GROUP ); - if ( is_int( $cached ) && 0 !== $cached ) { - return $cached; + + if ( is_numeric( $cached ) && 0 !== (int) $cached ) { + return (int) $cached; } $smart_links = new \WP_Query( @@ -1097,8 +1098,7 @@ public static function get_link_counts( int $post_id, string $status = Smart_Lin $cache_group = self::get_smart_links_post_cache_group( $post_id ); $link_counts = wp_cache_get( $cache_key, $cache_group ); - if ( false !== $link_counts ) { - /** @var array */ + if ( is_array( $link_counts ) ) { return $link_counts; } diff --git a/src/Utils/class-utils.php b/src/Utils/class-utils.php index d5b9789da5..089167d58a 100644 --- a/src/Utils/class-utils.php +++ b/src/Utils/class-utils.php @@ -430,8 +430,8 @@ public static function get_post_id_by_url( string $url ): int { $cache_key = sprintf( 'url-to-postid-%s', hash( 'sha256', $url ) ); $cache = wp_cache_get( $cache_key, PARSELY_CACHE_GROUP ); - if ( is_integer( $cache ) ) { - return $cache; + if ( is_numeric( $cache ) ) { + return (int) $cache; } if ( function_exists( 'wpcom_vip_url_to_postid' ) ) { From 6658a0f5db2a9ca15ae62c60048d89bdb7f57919 Mon Sep 17 00:00:00 2001 From: Alex Cicovic <23142906+acicovic@users.noreply.github.com> Date: Wed, 21 May 2025 18:44:02 +0300 Subject: [PATCH 2/5] Apply suggestions from code review Restore false check when checking cached value Co-authored-by: Alec Geatches --- src/Models/class-inbound-smart-link.php | 2 +- src/Models/class-smart-link.php | 4 ++-- src/Utils/class-utils.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Models/class-inbound-smart-link.php b/src/Models/class-inbound-smart-link.php index 65982cb125..0456db84d4 100644 --- a/src/Models/class-inbound-smart-link.php +++ b/src/Models/class-inbound-smart-link.php @@ -1069,7 +1069,7 @@ public static function get_suggestions_count( int $post_id ): int { $cache_key = self::get_suggestions_count_cache_key( $post_id ); $count = wp_cache_get( $cache_key, PARSELY_CACHE_GROUP ); - if ( is_numeric( $count ) ) { + if ( false !== $count && is_numeric( $count ) ) { return (int) $count; } diff --git a/src/Models/class-smart-link.php b/src/Models/class-smart-link.php index a35e6c00dc..212b1d4ba3 100644 --- a/src/Models/class-smart-link.php +++ b/src/Models/class-smart-link.php @@ -197,7 +197,7 @@ private function get_smart_link_object_by_uid( string $uid ): int { $cache_key = self::get_uid_to_smart_link_cache_key( $uid ); $cached = wp_cache_get( $cache_key, PARSELY_CACHE_GROUP ); - if ( is_numeric( $cached ) && 0 !== (int) $cached ) { + if ( false !== $cached && is_numeric( $cached ) ) { return (int) $cached; } @@ -1098,7 +1098,7 @@ public static function get_link_counts( int $post_id, string $status = Smart_Lin $cache_group = self::get_smart_links_post_cache_group( $post_id ); $link_counts = wp_cache_get( $cache_key, $cache_group ); - if ( is_array( $link_counts ) ) { + if ( false !== $link_counts && is_array( $link_counts ) ) { return $link_counts; } diff --git a/src/Utils/class-utils.php b/src/Utils/class-utils.php index 089167d58a..625337c9af 100644 --- a/src/Utils/class-utils.php +++ b/src/Utils/class-utils.php @@ -430,7 +430,7 @@ public static function get_post_id_by_url( string $url ): int { $cache_key = sprintf( 'url-to-postid-%s', hash( 'sha256', $url ) ); $cache = wp_cache_get( $cache_key, PARSELY_CACHE_GROUP ); - if ( is_numeric( $cache ) ) { + if ( false !== $cache && is_numeric( $cache ) ) { return (int) $cache; } From 402d407713bf99a3da35500203ae7c364f2f26c5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 21 May 2025 18:06:33 +0000 Subject: [PATCH 3/5] Update wp-parsely version number to 3.19.1 --- README.md | 2 +- package-lock.json | 4 ++-- package.json | 2 +- tests/e2e/utils.ts | 2 +- wp-parsely.php | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c9a30e5c9b..031fc7f2fb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Parse.ly -Stable tag: 3.19.0 +Stable tag: 3.19.1 Requires at least: 6.0 Tested up to: 6.8 Requires PHP: 7.2 diff --git a/package-lock.json b/package-lock.json index ee52d36c49..5d9cf41de6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "wp-parsely", - "version": "3.19.0", + "version": "3.19.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "wp-parsely", - "version": "3.19.0", + "version": "3.19.1", "license": "GPL-2.0-or-later", "dependencies": { "@types/js-cookie": "^3.0.6", diff --git a/package.json b/package.json index 97f071cdd0..d79b6c882c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wp-parsely", - "version": "3.19.0", + "version": "3.19.1", "private": true, "description": "The Parse.ly plugin facilitates real-time and historical analytics to your content through a platform designed and built for digital publishing.", "author": "parsely, hbbtstar, jblz, mikeyarce, GaryJ, parsely_mike, acicovic, mehmoodak, vaurdan", diff --git a/tests/e2e/utils.ts b/tests/e2e/utils.ts index cfc0669367..4e4e236415 100644 --- a/tests/e2e/utils.ts +++ b/tests/e2e/utils.ts @@ -8,7 +8,7 @@ import { type Page } from '@playwright/test'; */ import { Admin } from '@wordpress/e2e-test-utils-playwright'; -export const PLUGIN_VERSION = '3.19.0'; +export const PLUGIN_VERSION = '3.19.1'; export const VALID_SITE_ID = 'demoaccount.parsely.com'; export const INVALID_SITE_ID = 'invalid.parsely.com'; export const VALID_API_SECRET = 'valid_api_secret'; diff --git a/wp-parsely.php b/wp-parsely.php index 59ab597308..f6cc716465 100644 --- a/wp-parsely.php +++ b/wp-parsely.php @@ -11,7 +11,7 @@ * Plugin Name: Parse.ly * Plugin URI: https://docs.parse.ly/wordpress * Description: This plugin makes it a snap to add Parse.ly tracking code and metadata to your WordPress blog. - * Version: 3.19.0 + * Version: 3.19.1 * Author: Parse.ly * Author URI: https://www.parse.ly * Text Domain: wp-parsely From 18cc17de844277048af5f19a5c0c57ef7b54e8d9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 21 May 2025 18:06:38 +0000 Subject: [PATCH 4/5] Update CHANGELOG.md for version 3.19.1 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7364bfbe00..102b0766cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.19.1](https://github.com/Parsely/wp-parsely/compare/3.19.0...3.19.1) - 2025-05-21 + +### Fixed + +- Make some caching checks more flexible ([#3351](https://github.com/Parsely/wp-parsely/pull/3351)) + + ## [3.19.0](https://github.com/Parsely/wp-parsely/compare/3.18.1...3.19.0) - 2025-05-20 ### Added From 20da76793b810be01a49642478746dcf38f166e5 Mon Sep 17 00:00:00 2001 From: Alex Cicovic <23142906+acicovic@users.noreply.github.com> Date: Wed, 21 May 2025 21:09:55 +0300 Subject: [PATCH 5/5] wp-parsely.php: Change additional version number --- CHANGELOG.md | 1 - wp-parsely.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 102b0766cd..abedd044e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Make some caching checks more flexible ([#3351](https://github.com/Parsely/wp-parsely/pull/3351)) - ## [3.19.0](https://github.com/Parsely/wp-parsely/compare/3.18.1...3.19.0) - 2025-05-20 ### Added diff --git a/wp-parsely.php b/wp-parsely.php index f6cc716465..848871c6ff 100644 --- a/wp-parsely.php +++ b/wp-parsely.php @@ -49,7 +49,7 @@ return; } -const PARSELY_VERSION = '3.19.0'; +const PARSELY_VERSION = '3.19.1'; const PARSELY_FILE = __FILE__; const PARSELY_DATA_SCHEMA_VERSION = '1'; const PARSELY_CACHE_GROUP = 'wp-parsely';