Visitar URL original
Add filter to prevent wp_gf_feed_processor loopback by szepeviktor · Pull Request #73 · szepeviktor/wordpress-website-lifecycle · GitHub
Skip to content

Add filter to prevent wp_gf_feed_processor loopback - #73

Merged
szepeviktor merged 1 commit into
masterfrom
szepeviktor-patch-1
Aug 19, 2026
Merged

szepeviktor merged 1 commit into
masterfrom
szepeviktor-patch-1

Conversation

@szepeviktor

@szepeviktor szepeviktor commented Aug 19, 2026 •

Copy link
Copy Markdown
Owner

Summary by cubic

Prevents the Gravity Forms wp_gf_feed_processor loopback after an entry is saved to reduce self-HTTP calls and avoid timeouts. Old behavior: a loopback to admin-ajax?action=wp_gf_feed_processor ran after each save. New behavior: the request is intercepted via pre_http_request and returned as HTTP 200 immediately; other HTTP calls are unchanged.

  • Scope: only during the request that saves the entry; other requests and endpoints are unaffected.
  • Impact: async feed processing via the AJAX endpoint will not run. Verify add-ons that rely on async processing still work (they may process on save).
  • Migration: none required. If you need the loopback, remove this filter or guard it by environment.

Written for commit 8c02bf3. Summary will update on new commits.

Review in cubic

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Prevents Gravity Forms feed processor loopback requests after entry saves.

Changes:

  • Adds a scoped pre_http_request filter.
  • Returns a synthetic HTTP 200 response for feed processor requests.
Suppressed comments (1)

mu-plugins/gravityforms.php:58

  • This overwrites any response already supplied by an earlier pre_http_request callback. Because this callback runs at PHP_INT_MAX, a policy filter that returned a WP_Error (such as the repository's _core-migration.php:26) is converted into a successful response. Preserve any non-false $pre value before applying this special case.
                return ['response' => ['code' => 200]];

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +54 to +55
parse_str(parse_url($url, PHP_URL_QUERY) ?: '', $query);
if (($query['action'] ?? '') !== 'wp_gf_feed_processor') {

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 issues found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="mu-plugins/gravityforms.php">

<violation number="1" location="mu-plugins/gravityforms.php:48">
P2: When one request saves multiple entries, this line registers another anonymous HTTP filter for every entry and never removes it. Guard the registration so the filter is added once per request.</violation>

<violation number="2" location="mu-plugins/gravityforms.php:55">
P1: Restrict this short-circuit to the site's `admin-ajax.php` endpoint as well as the `action` query value. `pre_http_request` runs for every WordPress HTTP request, so a webhook or feed URL carrying `action=wp_gf_feed_processor` is replaced with a fake 200 response instead of being sent.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

'pre_http_request',
static function ($pre, $args, $url) {
parse_str(parse_url($url, PHP_URL_QUERY) ?: '', $query);
if (($query['action'] ?? '') !== 'wp_gf_feed_processor') {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: Restrict this short-circuit to the site's admin-ajax.php endpoint as well as the action query value. pre_http_request runs for every WordPress HTTP request, so a webhook or feed URL carrying action=wp_gf_feed_processor is replaced with a fake 200 response instead of being sent.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At mu-plugins/gravityforms.php, line 55:

<comment>Restrict this short-circuit to the site's `admin-ajax.php` endpoint as well as the `action` query value. `pre_http_request` runs for every WordPress HTTP request, so a webhook or feed URL carrying `action=wp_gf_feed_processor` is replaced with a fake 200 response instead of being sent.</comment>

<file context>
@@ -44,6 +44,28 @@ static function ($plugin_meta, $plugin_file) {
+            'pre_http_request',
+            static function ($pre, $args, $url) {
+                parse_str(parse_url($url, PHP_URL_QUERY) ?: '', $query);
+                if (($query['action'] ?? '') !== 'wp_gf_feed_processor') {
+                    return $pre;
+                }
</file context>
Suggested change
if (($query['action'] ?? '') !== 'wp_gf_feed_processor') {
if (
($query['action'] ?? '') !== 'wp_gf_feed_processor'
|| wp_parse_url($url, PHP_URL_SCHEME) !== wp_parse_url(admin_url('admin-ajax.php'), PHP_URL_SCHEME)
|| wp_parse_url($url, PHP_URL_HOST) !== wp_parse_url(admin_url('admin-ajax.php'), PHP_URL_HOST)
|| wp_parse_url($url, PHP_URL_PORT) !== wp_parse_url(admin_url('admin-ajax.php'), PHP_URL_PORT)
|| wp_parse_url($url, PHP_URL_PATH) !== wp_parse_url(admin_url('admin-ajax.php'), PHP_URL_PATH)
) {

);

// Prevent wp_gf_feed_processor loopback request.
add_filter(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: When one request saves multiple entries, this line registers another anonymous HTTP filter for every entry and never removes it. Guard the registration so the filter is added once per request.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At mu-plugins/gravityforms.php, line 48:

<comment>When one request saves multiple entries, this line registers another anonymous HTTP filter for every entry and never removes it. Guard the registration so the filter is added once per request.</comment>

<file context>
@@ -44,6 +44,28 @@ static function ($plugin_meta, $plugin_file) {
 );
 
+// Prevent wp_gf_feed_processor loopback request.
+add_filter(
+    'gform_entry_post_save',
+    static function ($entry) {
</file context>
Suggested change
add_filter(
static $filter_added = false;
if ($filter_added) {
return $entry;
}
$filter_added = true;
add_filter(

@szepeviktor
szepeviktor merged commit e53ebfe into master Aug 19, 2026
8 checks passed
@szepeviktor
szepeviktor deleted the szepeviktor-patch-1 branch August 19, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants