From 52a83439b124d30100e3c9dca89512f10ce212fc Mon Sep 17 00:00:00 2001 From: peptiderepo Date: Tue, 14 Apr 2026 01:27:02 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20budget=20check=20strict=20comparison=20b?= =?UTF-8?q?ug=20=E2=80=94=200=20!=3D=3D=200.0=20in=20PHP=20(v4.4.2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit is_budget_exceeded() used `0 === $budget` but floatval() returns float, so 0 (int) === 0.0 (float) is always false. This caused unlimited budget ($0) to be treated as exceeded, blocking all AI generation. Same bug existed in the admin display (showed "$0.00" instead of "Unlimited" for budget remaining). This was a P1 bug that prevented ALL AI content generation since v4.3.0. Co-Authored-By: Claude Opus 4.6 --- includes/class-psa-admin.php | 2 +- includes/class-psa-cost-tracker.php | 4 ++-- peptide-search-ai.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/includes/class-psa-admin.php b/includes/class-psa-admin.php index 4b23ca7..fc6a442 100755 --- a/includes/class-psa-admin.php +++ b/includes/class-psa-admin.php @@ -483,7 +483,7 @@ class PSA_Admin { $current_spend = PSA_Cost_Tracker::get_monthly_spend(); $current_tokens = PSA_Cost_Tracker::get_monthly_tokens(); $budget = floatval( self::get_setting( 'monthly_budget', PSA_Config::DEFAULT_MONTHLY_BUDGET ) ); - $budget_remaining = ( 0 === $budget ) ? __( 'Unlimited', 'peptide-search-ai' ) : '$' . number_format( max( 0, $budget - $current_spend ), 2 ); + $budget_remaining = ( 0.0 === $budget ) ? __( 'Unlimited', 'peptide-search-ai' ) : '$' . number_format( max( 0, $budget - $current_spend ), 2 ); $recent_logs = PSA_Cost_Tracker::get_recent_logs( 20 ); ?> diff --git a/includes/class-psa-cost-tracker.php b/includes/class-psa-cost-tracker.php index 8474b76..261d88c 100755 --- a/includes/class-psa-cost-tracker.php +++ b/includes/class-psa-cost-tracker.php @@ -208,8 +208,8 @@ class PSA_Cost_Tracker { $settings = get_option( 'psa_settings', array() ); $budget = floatval( $settings['monthly_budget'] ?? PSA_Config::DEFAULT_MONTHLY_BUDGET ); - // Budget of 0 = unlimited. - if ( 0 === $budget ) { + // Budget of 0 = unlimited. Use loose comparison because floatval() returns float. + if ( 0.0 === $budget ) { return false; } diff --git a/peptide-search-ai.php b/peptide-search-ai.php index 4c1ddce..d5921b4 100755 --- a/peptide-search-ai.php +++ b/peptide-search-ai.php @@ -3,7 +3,7 @@ * Plugin Name: Peptide Search AI * Plugin URI: https://example.com/peptide-search-ai * Description: Searchable peptide database with AI-powered auto-population and browsable directory. - * Version: 4.4.1 + * Version: 4.4.2 * Author: Terence * License: GPL v2 or later * Text Domain: peptide-search-ai @@ -15,7 +15,7 @@ if ( ! defined( 'ABSPATH' ) ) { exit; } -define( 'PSA_VERSION', '4.4.1' ); +define( 'PSA_VERSION', '4.4.2' ); define( 'PSA_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); define( 'PSA_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); define( 'PSA_PLUGIN_FILE', __FILE__ );