Skip to content

Fix PHP 8 warning on non WP GraphQL post types#812

Merged
apmatthews merged 1 commit into
canaryfrom
MERL-186
Mar 17, 2022
Merged

Fix PHP 8 warning on non WP GraphQL post types#812
apmatthews merged 1 commit into
canaryfrom
MERL-186

Conversation

@apmatthews
Copy link
Copy Markdown
Member

Description

Post types that aren't registered with WP GraphQL (like ACF field groups) don't have a graphql_single_name property. As of PHP 8, accessing undefined properties on objects results in a warning rather than a notice.

This fix checks that the graphql_single_name property exists and is not empty before adding a typeName to the preview link.

Related Issue(s):

Fixes #752
Related: #809

Testing

Unit test case has been added. The test case should fail in the absence of this patch regardless of what PHP version the tests are running on because our test config converts both PHP warnings and notices to exceptions. 🥳

@apmatthews apmatthews requested a review from a team as a code owner March 16, 2022 15:42
Copy link
Copy Markdown
Contributor

@blakewilson blakewilson left a comment

Choose a reason for hiding this comment

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

LGTM

@apmatthews apmatthews merged commit a90eff5 into canary Mar 17, 2022
@apmatthews apmatthews deleted the MERL-186 branch March 17, 2022 13:34
apmatthews added a commit that referenced this pull request Mar 17, 2022
apmatthews added a commit that referenced this pull request Mar 21, 2022
@github-actions github-actions Bot mentioned this pull request Mar 21, 2022
@esilverman682
Copy link
Copy Markdown

Does this mean that the error will still show?

@blakewilson
Copy link
Copy Markdown
Contributor

@esilverman682 👋

We'll be releasing v0.7.7 of the FaustWP plugin tomorrow with this fix in place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Unable to create/edit Custom Fields (ACF) with FaustWP 7.3

3 participants