Skip to content

Omit changelog from autoloaded option with plugin api data and exclude invalid plugins#2829

Merged
Crabcyborg merged 13 commits into
masterfrom
omit_changelog_from_autoloaded_option_with_plugin_api_data
Jan 19, 2026
Merged

Omit changelog from autoloaded option with plugin api data and exclude invalid plugins#2829
Crabcyborg merged 13 commits into
masterfrom
omit_changelog_from_autoloaded_option_with_plugin_api_data

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

@Crabcyborg Crabcyborg commented Jan 19, 2026

Related ticket https://secure.helpscout.net/conversation/3202737995/245662

With this update, the stored option data is now ~57kb, down from the previous ~142kb, reducing the size down to 40% of what it was.

What this update does

  • Remove changelog and banners from the cached data.
  • Remove all plugins from the data that are missing version data.
  • Remove all plugins (except for legacy views) that are missing categories data.
  • Forces an API request when someone checks for a plugin's changelog.

Pre-release
formidable-6.27.1b.zip

Summary by CodeRabbit

  • Improvements

    • Fetches fresh plugin/addon info when available so changelogs and banner data stay current.
    • Default display data now includes changelog and banner references when API data is absent.
  • Performance

    • Reduces addon payload before caching by omitting non-essential or inactive entries to shrink cache size.
  • Tests

    • Acceptance test broadened to allow an additional upgrade-page heading variant.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 19, 2026

📝 Walkthrough

Walkthrough

Adds a force flag and public method to bypass the API cache for fresh addon data; FrmFormApi now prunes non-essential addon fields (changelog, banners) before caching; FrmAddon uses the forced API request when an item_id is present and otherwise falls back to default data.

Changes

Cohort / File(s) Summary
API class & caching
classes/models/FrmFormApi.php
Added protected $force; force_api_request() to set it; get_api_info() bypasses cache when forced and resets flag; set_cached() prunes addon payload via reduce_addon_data_before_caching(); added reduce_addon_data_before_caching() and should_include_addon_in_cached_data() (private).
Addon plugin filter
classes/models/FrmAddon.php
plugins_api_filter now constructs FrmFormApi, calls force_api_request() and fetches API info only when item_id is present; default data array updated to include changelog and banners; removed unconditional API-fetch path in the non-item_id branch.
Test expectation
tests/cypress/e2e/Applications/validateApplicationsPage.cy.js
Expanded H1 text matching to accept an additional heading variant in the upgrade-flow validation.

Sequence Diagram(s)

sequenceDiagram
    participant Addon as FrmAddon
    participant API as FrmFormApi
    participant Cache as CacheStore
    participant Remote as RemoteAPI

    Addon->>API: new FrmFormApi()
    Addon->>API: force_api_request()
    Note right of API: $force = true
    API->>Cache: check cached addons
    alt force flag set
        API->>Remote: fetch fresh addon data
        Remote-->>API: return fresh data
        API->>API: reduce_addon_data_before_caching()
        API->>Cache: set_cached(reduced data)
    else force not set
        Cache-->>API: return cached data (if present)
        alt cache miss
            API->>Remote: fetch remote data
            Remote-->>API: return data
            API->>API: reduce_addon_data_before_caching()
            API->>Cache: set_cached(reduced data)
        end
    end
    API-->>Addon: return addon info (possibly reduced)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • lauramekaj1

Poem

🐰 I poked the API, said “fresh, please,”

Skip the stale cache, trim extra keys.
Changelogs tucked, banners kept light,
Cached and tidy, hopped out of sight. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main changes: omitting changelog from autoloaded plugin API data and excluding invalid plugins from cached storage.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@classes/models/FrmAddon.php`:
- Around line 209-216: Guard against an empty API response from
FrmFormApi::get_api_info() before indexing into $plugins[$item_id]; check that
$plugins is a non-empty array and isset($plugins[$item_id]) (or
array_key_exists) and only then set $_data = $plugins[$item_id]; otherwise fall
back to the original data (e.g., the local $data variable or existing source
used before this block) so subsequent uses of $_data['sections'] won't emit
warnings.
🧹 Nitpick comments (1)
classes/models/FrmFormApi.php (1)

389-426: Consider removing banners even when changelog is absent.

Right now banners are only removed when changelog exists. If the goal is payload reduction, unsetting banners independently is more consistent.

♻️ Suggested tweak
-			if ( isset( $addon['changelog'] ) ) {
-				unset( $addon['changelog'], $addon['banners'] );
-			}
+			if ( isset( $addon['changelog'] ) ) {
+				unset( $addon['changelog'] );
+			}
+			if ( isset( $addon['banners'] ) ) {
+				unset( $addon['banners'] );
+			}

Comment thread classes/models/FrmAddon.php Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@classes/models/FrmFormApi.php`:
- Around line 413-417: Remove the transient debug log call inside the addon
version check: delete the error_log('Omitting ' . $addon['slug'] . ' (Version)')
line within the conditional that checks isset($addon['version']) && '' ===
$addon['version') so the loop continues without emitting debug output; ensure
the surrounding logic in FrmFormApi (the block that references $addon['version']
and $addon['slug']) remains unchanged.

Comment thread classes/models/FrmFormApi.php Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@classes/models/FrmFormApi.php`:
- Around line 441-446: The current check only runs when $addon['categories'] key
exists, so missing categories slip through; update the logic around
$categories_are_empty and the conditional so that absent or falsy
$addon['categories'] is treated as empty (e.g., use empty($addon['categories'])
or !isset(...) || empty(...)) and keep the existing exception for legacy views
by still checking $is_legacy_views (slug 'views'), then return false for addons
with missing/empty categories except the legacy views case.
♻️ Duplicate comments (1)
classes/models/FrmFormApi.php (1)

435-437: Remove debug logging before merge.

This debug error_log() will pollute production logs.

🔧 Proposed fix
-        if ( isset( $addon['version'] ) && '' === $addon['version'] ) {
-            error_log( 'Omitting ' . $addon['slug'] . ' (Version)' );
+        if ( isset( $addon['version'] ) && '' === $addon['version'] ) {
             // If version is set but blank, the plugin is not actually live.
             return false;
         }

Comment thread classes/models/FrmFormApi.php
@Crabcyborg Crabcyborg changed the title Omit changelog from autoloaded option with plugin api data Omit changelog from autoloaded option with plugin api data and exclude invalid plugins Jan 19, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@classes/models/FrmFormApi.php`:
- Around line 417-419: The current conditional only unsets $addon['banners']
when $addon['changelog'] exists, leaving banners in cache for addons without
changelog; remove the surrounding if (isset($addon['changelog'])) check in
FrmFormApi:: (the block handling $addon) and always call
unset($addon['changelog'], $addon['banners']); directly so both keys are pruned
regardless of which one exists.
♻️ Duplicate comments (1)
classes/models/FrmFormApi.php (1)

440-452: Addons missing the categories key are not excluded.

The PR objective states to remove plugins missing categories data, but the current logic only evaluates categories when the key exists. Addons without a categories key will bypass this check and return true (included), contradicting the stated objective.

🔧 Proposed fix
-	if ( isset( $addon['categories'] ) ) {
-		if ( 'views' === $addon['slug'] ) {
-			// Legacy views has no categories set, but we should still
-			// include it in cache since it is a valid add-on.
-			return true;
-		}
-
-		$categories_are_empty = ! $addon['categories'] || $addon['categories'] === array( 'Strategy11' );
-
-		if ( $categories_are_empty ) {
-			return false;
-		}
-	}
-
-	return true;
+	$is_legacy_views      = isset( $addon['slug'] ) && 'views' === $addon['slug'];
+	$categories           = $addon['categories'] ?? array();
+	$categories_are_empty = ! $categories || $categories === array( 'Strategy11' );
+
+	if ( $categories_are_empty && ! $is_legacy_views ) {
+		return false;
+	}
+
+	return true;

Comment thread classes/models/FrmFormApi.php
@Crabcyborg Crabcyborg merged commit 242d018 into master Jan 19, 2026
15 of 16 checks passed
@Crabcyborg Crabcyborg deleted the omit_changelog_from_autoloaded_option_with_plugin_api_data branch January 19, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant