Skip to content

Stop PDFs crashing on Gravity Forms before 2.8.2 when a field leaves a gap in its row (6.18.0) - #1966

Merged
jakejackson1 merged 3 commits into
hot-patch-6.18.0from
fix-gf-row-spacer-guard-6.18
Oct 26, 2026
Merged

jakejackson1 merged 3 commits into
hot-patch-6.18.0from
fix-gf-row-spacer-guard-6.18

Conversation

@gravitypdf-bot

Copy link
Copy Markdown
Contributor

Summary

Backport of #1965 to 6.18.0. PDFs of forms using the Gravity Forms 2.5+ column layout fatal on Gravity Forms 2.5–2.8.1 when a field leaves empty space at the end of its row. The field container calls GFFormDisplay::get_row_spacer(), which Gravity Forms only added in 2.8.2, while Gravity PDF still allows 2.5+. On older versions the container now ends the row the way Gravity Forms did back then.

  • Guard the GFFormDisplay::get_row_spacer() call with method_exists()
  • Before 2.8.2, end the row after any field with a spacer value, matching Gravity Forms' own output on those versions
  • No change on Gravity Forms 2.8.2+
  • CHANGELOG line under 6.18.0

Try it

gh pr checkout fix-gf-row-spacer-guard-6.18 --repo GravityPDF/gravity-pdf
vendor/bin/phpunit --filter Container

By hand (needs Gravity Forms 2.6–2.8.1): on a form with legacy markup off, put two half-width fields in a row and a third half-width field on the next row by itself, submit an entry and view a Core PDF. Before this change the PDF fatals with "Call to undefined method GFFormDisplay::get_row_spacer()"; now it renders with the same rows as the form.

Test plan

  • Gravity Forms 2.8.2+: column layout in the PDF is unchanged
  • Gravity Forms older than 2.8.2: a form with a partly empty row renders instead of fataling
  • Container tests pass
More info

Found by an audit of hot-patch-6.18.0 for Gravity Forms symbols newer than the 2.5 floor; this was the only unguarded call that fatals. get_row_spacer() is @since 2.8.2 in Gravity Forms 3.2 and is missing from the 2.6.1 and 2.6-beta1 copies checked.

Gravity Forms 2.6.1 (form_display.php:1119) outputs a spacer after every field whose layoutSpacerGridColumnSpan is set when legacy markup is off. Helper_Field_Container_Gf25 is only used when legacy markup is off (View_PDF.php:242, Field_Form.php:128), and the block already requires a non-empty layoutSpacerGridColumnSpan, so the fallback just marks the end of the row. 2.8.2's version only adds the spacer to the last field in a layout group, which is why the newer path still asks Gravity Forms.

Same source change as #1965, minus its PHPStan baseline entry (6.18 has no PHPStan). The CHANGELOG line is added at the end of the 🐞 Bug group under 6.18.0.

No new test: PHPUnit runs against Gravity Forms 3.x, where the method always exists, so the fallback can't be reached without stubbing a static method. Checks run locally: container PHPUnit tests (18 passing), PHPCS lint + PHP compatibility clean, run on the 6.18 build. Not checked on a real Gravity Forms 2.x install.

🤖 Generated with AI

…a gap in its row (6.18.0)

Backport of #1965, without the PHPStan baseline entry (6.18 has no PHPStan).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jakejackson1
jakejackson1 merged commit cfff080 into hot-patch-6.18.0 Oct 26, 2026
8 of 12 checks passed
@jakejackson1
jakejackson1 deleted the fix-gf-row-spacer-guard-6.18 branch October 26, 2026 06:57
@gravitypdf-bot gravitypdf-bot mentioned this pull request Oct 26, 2026
2 tasks
jakejackson1 pushed a commit that referenced this pull request Oct 27, 2026
)

* fix: end the row after a field that leaves a gap at the end of its row

Helper_Field_Container_Gf25 looked the form up with $field->form_id, but Gravity Forms fields use formId, so the form
was never found. A field that leaves a gap at the end of its row (a spacer) never ended the row, and the next field
moved up into the gap. This also left the get_row_spacer() call #1966 guards unreachable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: create the spacer test's form with the Gravity Forms test factory

Integration tests can't call GFAPI::add_form() directly; CI's fixture check rejects it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Greg <gregory@gravitypdf.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
jakejackson1 added a commit that referenced this pull request Oct 27, 2026
#1975)

Helper_Field_Container_Gf25 looked the form up with $field->form_id, but Gravity Forms fields use formId, so the form
was never found. A field that leaves a gap at the end of its row (a spacer) never ended the row, and the next field
moved up into the gap. This also left the get_row_spacer() call #1966 guards unreachable.

Co-authored-by: Greg <gregory@gravitypdf.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants