GravityPDF / gravity-pdf

Gravity PDF is a GPLv2-licensed WordPress plugin that allows you to automatically generate, email and download PDF documents using Gravity Forms.
https://gravitypdf.com
89 stars 21 forks source link

Fix PHP notice when $rule is not a valid array #1508

Closed jakejackson1 closed 3 months ago

jakejackson1 commented 3 months ago

Description

Return early when $rule is not an array.

Had use report of the following PHP warning showing multiple times in their PDF document:

Warning: Trying to access array offset on value of type null in /wp-content/plugins/gravity-forms-pdf-extended/src/Controller/Controller_Form_Settings.php on line 346

Testing instructions

The only way I could replicate this was by using a filter to modify the rule:

add_filter( 'gform_rule_pre_evaluation', function ( $rule ) {
    return null;
} );

The PR fixes the Gravity PDF-related errors. But if you use the filter, it does cause other errors to be triggered in the PDF by Gravity Forms. It's a case of bad input/bad output, so fixing the input problem (removing the bad filter) is the way forward.

Screenshots

Checklist:

Additional Comments

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 76.97%. Comparing base (fd0baa1) to head (e4a7e1e).

:exclamation: Current head e4a7e1e differs from pull request most recent head f99f629. Consider uploading reports for the commit f99f629 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## development #1508 +/- ## ============================================ Coverage 76.97% 76.97% ============================================ Files 244 244 Lines 12740 12741 +1 Branches 370 370 ============================================ + Hits 9807 9808 +1 Misses 2925 2925 Partials 8 8 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.