Skip to content

Fix JSON-LD entity type comparison to be case-insensitive#499

Merged
duncanmcclean merged 6 commits intostatamic:7.xfrom
samalisam-novu:fix/site-defaults-jsonld-entities
Feb 18, 2026
Merged

Fix JSON-LD entity type comparison to be case-insensitive#499
duncanmcclean merged 6 commits intostatamic:7.xfrom
samalisam-novu:fix/site-defaults-jsonld-entities

Conversation

@samalisam-novu
Copy link
Contributor

@samalisam-novu samalisam-novu commented Feb 17, 2026

Summary

The json_ld_entity button group field in the site defaults Blueprint stores lowercase keys (organization, person), but the comparisons in Cascade::jsonLd() checked against capitalized strings (Organization, Person). Since PHP's === is case-sensitive, the JSON-LD Organization and Person structured data snippets were never rendered.

Changes

  • Normalize json_ld_entity value with strtolower() before comparison in Cascade::jsonLd(), making the check case-insensitive
  • Update existing test to use lowercase entity values matching what the Blueprint actually stores
  • Add tests for uppercase entity values to ensure backward compatibility

Steps to reproduce

  1. Set the JSON-LD entity to "Organization" and provide an organization name in SEO Pro site defaults
  2. Query an entry via GraphQL:
   query {
     entry(site: "de", uri: "", collection: "pages") {
       seo {
         html
       }
     }
   }
  1. The html field contains no <script type="application/ld+json"> tag with the Organization schema

Expected: A JSON-LD Organization snippet should be present in the output.

Copy link
Member

@duncanmcclean duncanmcclean left a comment

Choose a reason for hiding this comment

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

Thanks for the pull request!

The JSON LD entity should always be lowercase though, so I've reverted your commits and adjusted the code.

'options' => [
'organization' => __('seo-pro::messages.organization'),
'person' => __('seo-pro::messages.person'),
],

They were incorrectly title case to start with (#440) but it was fixed in #458.

@duncanmcclean duncanmcclean merged commit 513bc94 into statamic:7.x Feb 18, 2026
6 checks passed
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.

2 participants