-
Notifications
You must be signed in to change notification settings - Fork 91
gw-shortcode-attr-field-props.php
: Fixed potential PHP warnings.
#1119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
WalkthroughA new private property named Changes
Suggested reviewers
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
gravity-forms/gw-shortcode-attr-field-props.php
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Danger JS
🔇 Additional comments (1)
gravity-forms/gw-shortcode-attr-field-props.php (1)
34-34
: Explicit initialization of$_field_props
is correct
Initializing$_field_props
as an empty array prevents potential “undefined property” warnings when parsing or stashing shortcode attributes.
@@ -30,7 +30,8 @@ | |||
*/ | |||
class GW_Shortcode_Attr_Field_Props { | |||
|
|||
private $_field_props; | |||
private $_args = array(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing assignment of constructor arguments to $_args
The new $_args
property is declared but never populated from the $args
passed into __construct
. As a result, is_applicable_form()
will always see an empty $_args['form_id']
and never filter by form.
Apply this diff to fix:
public function __construct( $args = array() ) {
- // do version check in the init to make sure if GF is going to be loaded, it is already loaded
- add_action( 'init', array( $this, 'init' ) );
+ // capture constructor args to support form-specific filtering
+ $this->_args = $args;
+ // do version check in the init to make sure if GF is going to be loaded, it is already loaded
+ add_action( 'init', array( $this, 'init' ) );
}
🤖 Prompt for AI Agents
In gravity-forms/gw-shortcode-attr-field-props.php at line 33, the private
property $_args is declared but never assigned the constructor's $args
parameter. To fix this, update the __construct method to assign the passed $args
to $this->_args so that $_args contains the expected data, enabling
is_applicable_form() to correctly access $_args['form_id'] for filtering.
Context
⛑️ Ticket(s): https://secure.helpscout.net/conversation/2960746738/84687
Summary
Assigning
$_args
toarray()
.We did a lot of these here. Somehow this one was left out. 😬