Skip to content

Commit 20873bb

Browse files
committed
Prevent fatal error when AUTH_KEY/SECURE_AUTH_KEY are undefined
1 parent ed8eba1 commit 20873bb

3 files changed

Lines changed: 24 additions & 3 deletions

File tree

gravityforms-zero-spam.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Gravity Forms Zero Spam
44
* Plugin URI: https://www.gravitykit.com?utm_source=plugin&utm_campaign=zero-spam&utm_content=pluginuri
55
* Description: Enhance Gravity Forms to include effective anti-spam measures—without using a CAPTCHA.
6-
* Version: 1.7.0
6+
* Version: 1.7.1
77
* Author: GravityKit
88
* Author URI: https://www.gravitykit.com?utm_source=plugin&utm_campaign=zero-spam&utm_content=authoruri
99
* Requires PHP: 7.4

includes/class-gf-zero-spam-token.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,24 @@ public static function validate( string $token, int $expected_form_id ): array {
152152
* @return string The derived HMAC secret.
153153
*/
154154
public static function get_site_secret( int $salt_version ): string {
155-
return hash_hmac( 'sha256', $salt_version . '|' . AUTH_KEY, SECURE_AUTH_KEY );
155+
$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
156+
$secure_auth_key = defined( 'SECURE_AUTH_KEY' ) ? SECURE_AUTH_KEY : '';
157+
158+
// Fall back to a DB-stored secret if wp-config.php salts are missing.
159+
if ( '' === $auth_key && '' === $secure_auth_key ) {
160+
$fallback = get_option( 'gf_zero_spam_fallback_secret' );
161+
162+
if ( ! $fallback ) {
163+
$fallback = wp_generate_password( 64, true, true );
164+
165+
update_option( 'gf_zero_spam_fallback_secret', $fallback, false );
166+
}
167+
168+
$auth_key = $fallback;
169+
$secure_auth_key = $fallback;
170+
}
171+
172+
return hash_hmac( 'sha256', $salt_version . '|' . $auth_key, $secure_auth_key );
156173
}
157174

158175
/**

readme.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: gravityview
33
Tags: gravity forms, spam, captcha, honeypot, anti-spam
44
Requires at least: 4.7
55
Tested up to: 6.9.1
6-
Stable tag: 1.7.0
6+
Stable tag: 1.7.1
77
Requires PHP: 7.4
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -110,6 +110,10 @@ You can enable a spam summary report email. This email will be sent to the email
110110

111111
== Changelog ==
112112

113+
= 1.7.1 on March 6, 2026 =
114+
115+
* Fixed: Fatal error on sites where `AUTH_KEY` or `SECURE_AUTH_KEY` constants are not defined in `wp-config.php`
116+
113117
= 1.7.0 on March 5, 2026 =
114118

115119
* Added: Stronger spam prevention using signed, time-limited tokens

0 commit comments

Comments
 (0)