From e705c5101ddb3351f6021eee62f0c23bd32be511 Mon Sep 17 00:00:00 2001 From: Ash Hitchcock Date: Mon, 7 Jun 2021 08:00:04 +0100 Subject: [PATCH] fix undefined meta properties --- CHANGELOG.md | 6 ++++++ readme.txt | 2 +- wp-graphql-yoast-seo.php | 22 ++++++++++++---------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4149d6..c224900 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [4.14.2] - 2021-06-07 + +### Changed + +- Guard against undefined meta properties + ## [4.14.1] - 2021-06-01 ### Added diff --git a/readme.txt b/readme.txt index 65c5fe8..26ceb22 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: SEO, Yoast, WPGraphQL, GraphQL, Headless WordPress, Decoupled WordPress, J Requires at least: 5.0 Tested up to: 5.7 Requires PHP: 7.1 -Stable tag: 4.14.1 +Stable tag: 4.14.2 License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.html diff --git a/wp-graphql-yoast-seo.php b/wp-graphql-yoast-seo.php index 14fc547..2d306dc 100755 --- a/wp-graphql-yoast-seo.php +++ b/wp-graphql-yoast-seo.php @@ -8,7 +8,7 @@ * Author URI: https://www.ashleyhitchcock.com * Text Domain: wp-graphql-yoast-seo * Domain Path: /languages - * Version: 4.14.1 + * Version: 4.14.2 * * @package WP_Graphql_YOAST_SEO */ @@ -1108,12 +1108,14 @@ function wp_gql_seo_build_content_type_data($types, $all) YoastSEO()->meta->for_term($term->term_id) ->description ), - 'focuskw' => wp_gql_seo_format_string( - $meta['wpseo_focuskw'] - ), - 'metaKeywords' => wp_gql_seo_format_string( - $meta['wpseo_metakeywords'] - ), + 'focuskw' => isset($meta['wpseo_focuskw']) + ? wp_gql_seo_format_string($meta['wpseo_focuskw']) + : $meta['wpseo_focuskw'], + 'metaKeywords' => isset($meta['wpseo_metakeywords']) + ? wp_gql_seo_format_string( + $meta['wpseo_metakeywords'] + ) + : null, 'metaRobotsNoindex' => $robots['index'], 'metaRobotsNofollow' => $robots['follow'], 'opengraphTitle' => wp_gql_seo_format_string( @@ -1174,9 +1176,9 @@ function wp_gql_seo_build_content_type_data($types, $all) ->load_deferred( absint($meta['wpseo_twitter-image-id']) ), - 'canonical' => wp_gql_seo_format_string( - $meta['canonical'] - ), + 'canonical' => isset($meta['canonical']) + ? wp_gql_seo_format_string($meta['canonical']) + : null, 'breadcrumbs' => YoastSEO()->meta->for_term( $term->term_id )->breadcrumbs,