Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion gravity-forms/gw-shortcode-attr-field-props.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
*/
class GW_Shortcode_Attr_Field_Props {

private $_field_props;
private $_args = array();
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

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.

private $_field_props = array();

public function __construct( $args = array() ) {

Expand Down
Loading