Skip to content

Commit 7b8909c

Browse files
committed
wp-proudcity#2829: gate GF Stripe rate-limiter disable on PC_DISABLE_GF_STRIPE_RATE_LIMIT env var
The filter is now applied only when the k8s pod is launched with PC_DISABLE_GF_STRIPE_RATE_LIMIT=true. Default behaviour is the unmodified GF Stripe rate limiter, so the workaround is opt-in per tenant via a workload-YAML env var rather than platform-wide. Pairs with the launch checklist note in pc-dev-issues/.github/ISSUE_TEMPLATE/launch.md and is tracked for removal under pc-dev-issues#287.
1 parent 92795d2 commit 7b8909c

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
<?php
22
/**
33
* Plugin Name: Disable GF Stripe IP Rate Limit
4-
* Description: Disables the Gravity Forms Stripe add-on per-IP rate limiter. Required while all
5-
* customers share the same internal k8s IP from WordPress's perspective, which causes
6-
* one customer's card errors to lock out every other customer for an hour.
7-
* Remove once the k8s ingress forwards the real client IP to PHP.
4+
* Description: Conditionally disables the Gravity Forms Stripe add-on per-IP rate
5+
* limiter when the k8s pod is launched with PC_DISABLE_GF_STRIPE_RATE_LIMIT=true.
6+
* Required while all customers share the same internal k8s IP from WordPress's
7+
* perspective (see pc-dev-issues#287), which causes one customer's card errors
8+
* to lock out every other customer for an hour. Set the env var per-tenant in
9+
* the deployment YAML so the override is opt-in and tracked, not platform-wide.
10+
* Once pc-dev-issues#287 lands, remove the env var from any pod that has it.
811
* Author: ProudCity
9-
* Version: 1.0.0
12+
* Version: 1.1.0
1013
*/
1114

1215
if ( ! defined( 'ABSPATH' ) ) {
1316
exit;
1417
}
1518

16-
add_filter( 'gform_stripe_enable_rate_limits', '__return_false' );
19+
// getenv() is used (rather than $_ENV) so it works under PHP-FPM regardless of
20+
// variables_order. Compared strictly to the literal string "true" so an unset
21+
// or any other value leaves the rate limiter enabled.
22+
if ( getenv( 'PC_DISABLE_GF_STRIPE_RATE_LIMIT' ) === 'true' ) {
23+
add_filter( 'gform_stripe_enable_rate_limits', '__return_false' );
24+
}

0 commit comments

Comments
 (0)