Skip to content
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

FSE: Form Blocks Added To Footer Template Part Show As Shortcodes on 404 pages #22749

Closed
katiebethbrown opened this issue Jan 31, 2022 · 12 comments · Fixed by #24870
Closed

FSE: Form Blocks Added To Footer Template Part Show As Shortcodes on 404 pages #22749

katiebethbrown opened this issue Jan 31, 2022 · 12 comments · Fixed by #24870
Assignees
Labels
[Block] Contact Form Form block (also see Contact Form label) Build Maintenance Build Group maintenance tasks Customer Report Issues or PRs that were reported via Happiness. aka "Happiness Request", or "User Report" [Feature] Contact Form [Focus] FSE Issues related to the site editor / Full Site Editing / FSE feature in Gutenberg [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Pri] Normal [Type] Bug When a feature is broken and / or not performing as intended

Comments

@katiebethbrown
Copy link

Quick summary

Jetpack Form Blocks added to the footer template part aren't displaying correctly on 404 pages. Instead the shortcode displays:

CleanShot 2022-01-31 at 14 08 45@2x

The form does show in the Site Editor when reviewing the 404 Template:

CleanShot 2022-01-31 at 14 09 39@2x

Steps to reproduce

  1. Use the Site Editor to create a custom footer that includes a Jetpack Contact Form
  2. Check the 404 Template to ensure the footer w/ the form shows in the editor.
  3. Visit a page on the live site that will 404.

What you expected to happen

For the form to show in the footer, like it does on the other pages of the site.

What actually happened

The form doesn't show. Instead we just see the unconverted shortcode.

Context

Found when working on a Team51 partner site. Replicated on a Premium plan test site.

You can see it happening on a simple site here:
https://kbb-premium.blog/404test

And on an atomic site here:
https://kbbatomicbusiness.wpcomstaging.com/404test

Simple, Atomic or both?

Simple, Atomic

Theme-specific issue?

I can replicate in Blockbase (in use on our partner site) and in other FSE-capable themes (tested Alonso).

Browser, operating system and other notes

No response

Reproducibility

Consistent

Severity

Most (> 50%)

Available workarounds?

No but the platform is still usable

Workaround details

No response

@simison
Copy link
Member

simison commented Feb 1, 2022

Interesting!

So templates don't render shortcodes, that's known.

I had impression (based on #15227 (comment)) that this shouldn't be an issue with contact form anymore. cc @jeherve

Indeed I see that contact form isn't outputting shortcodes:

Screenshot 2022-02-01 at 18 23 53

How did the shortcode end up in the template?

@katiebethbrown
Copy link
Author

How did the shortcode end up in the template?

@simison - Not sure if this question is for me or not, but in case it is - in the site we originally noticed the issue on, the form block is added to the Footer template part directly. We didn't add it using the shortcode, so it must be falling back to that (or trying to) somewhere.

CleanShot 2022-02-08 at 17 04 26@2x

@jeherve
Copy link
Member

jeherve commented Feb 9, 2022

This fallback is happening here:

if ( ! $id ) { // something terrible has happened
return '[contact-form]';
}

It's been set up that way since the contact form was first developed, years ago, but makes less sense now, when used in template parts. Unfortunately, forms are still tied to a post behind the scenes, and when used outside of a post context, you're bound to run into issues like this.

Here is a related issue with more discussion around the reason why we look for that post ID:
#102

I'll move this to the Jetpack repo, where the form block is developed.

@jeherve jeherve transferred this issue from Automattic/wp-calypso Feb 9, 2022
@jeherve jeherve added [Block] Contact Form Form block (also see Contact Form label) [Pri] Normal [Type] Bug When a feature is broken and / or not performing as intended [Feature] Contact Form [Focus] FSE Issues related to the site editor / Full Site Editing / FSE feature in Gutenberg [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Feb 9, 2022
@simison
Copy link
Member

simison commented Feb 9, 2022

Thanks for explaining @jeherve 👍

Why does contact form require page/post ID, and could it work without it?

Just thinking if the fix is to ensure it gets the ID, or remove the reliance on that ID altogether.

Edit: right so the gotcha is "... on 404 pages" which of course won't have any kind of ID. Would that also be the case with archive and search pages?

@jeherve
Copy link
Member

jeherve commented Feb 9, 2022

Why does contact form require page/post ID, and could it work without it?

There are some details about this here:
#102 (comment)

You can also dig a bit in projects/plugins/jetpack/modules/contact-form/grunion-contact-form.php to see how we use contact-form-id as a way to ensure the form that's being submitted makes sense.

Edit: right so the gotcha is "... on 404 pages" which of course won't have any kind of ID. Would that also be the case with archive and search pages?

Yep, if we do not have an ID, we have a problem. :|

@cuemarie
Copy link

cuemarie commented Mar 2, 2022

Ran into this issue here as well: 34459908-hc

Form block, along with all their content, was built directly onto the home template, which means the form didn't have a page ID, and therefore rendered as [contact-form] on the live site. I can see this happening more frequently with users who (perhaps mistakenly) build their content onto templates instead of onto pages, as they learn the ropes with FSE.

This user is taking a different approach and removing the form from the home template for the time being.

@matticbot matticbot added the Customer Report Issues or PRs that were reported via Happiness. aka "Happiness Request", or "User Report" label Mar 2, 2022
@edequalsawesome
Copy link

Same issue in 4762945-zen

@KokkieH
Copy link

KokkieH commented Apr 23, 2022

Another case in https://wordpress.com/forums/topic/contact-form-76/?view=all, using the form on the Home template.

@TPilgs
Copy link

TPilgs commented Jun 8, 2022

Another case here using the contact form on the index template: 35747249-hc

@danielbachhuber
Copy link
Contributor

@jeherve I think this issue might actually be fixed with #24727, too.

Using the following test environment:

  • Fresh WordPress install in my local environment.
  • Jetpack at 950ce39.
  • Twenty Twenty-Two active.

When I add a Contact Form Block to the 404 Template and the Footer Template Part, they both appear as expected on a 404 page:

image

image

Well, partially as expected: #24857

@jeherve
Copy link
Member

jeherve commented Jun 28, 2022

Ah yes, it looks better now. We're only left with a PHP notice on form submission:

PHP Notice:  Trying to get property 'ID' of non-object in /wp-content/plugins/jetpack-dev/modules/contact-form/grunion-contact-form.php on line 3507

@danielbachhuber
Copy link
Contributor

We're only left with a PHP notice on form submission:

@jeherve Nice catch! Fixed with #24870

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Contact Form Form block (also see Contact Form label) Build Maintenance Build Group maintenance tasks Customer Report Issues or PRs that were reported via Happiness. aka "Happiness Request", or "User Report" [Feature] Contact Form [Focus] FSE Issues related to the site editor / Full Site Editing / FSE feature in Gutenberg [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Pri] Normal [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
10 participants