statamic / seo-pro

An all-in-one site reporting, metadata wrangling, Open Graph managing, Twitter card making, sitemap generating, turn-key addon for Statamic.
https://statamic.com/addons/statamic/seo-pro
54 stars 36 forks source link

Error when using `@seo_pro('meta')` in a blade template #355

Open 321zeno opened 1 month ago

321zeno commented 1 month ago

Getting

TypeError
array_merge(): Argument #2 must be of type array, null given

php please support:details:

Environment
Application Name: Statamic
Laravel Version: 11.26.0
PHP Version: 8.3.11
Composer Version: 2.2.6
Environment: local
Debug Mode: ENABLED
URL: headless-cms.local
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: mysql
Logs: stack / daily
Mail: log
Queue: redis
Session: file

Statamic
Addons: 3
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.28.0 PRO

Statamic Addons
statamic-rad-pack/runway: 7.10.1
statamic/eloquent-driver: 4.15.0
statamic/seo-pro: 6.2.0

Statamic Eloquent Driver
Asset Containers: file
Assets: file
Blueprints: file
Collection Trees: eloquent
Collections: eloquent
Entries: eloquent
Forms: file
Global Sets: eloquent
Global Variables: eloquent
Navigation Trees: eloquent
Navigations: eloquent
Revisions: file
Sites: file
Taxonomies: file
Terms: eloquent
Tokens: file

After some debugging I notice in https://github.com/statamic/seo-pro/blob/master/src/Tags/SeoProTags.php#L39 $this->context->value('seo') is always null because the seo key is not set on the context.

I reviewed the setup instructions a few times but I can't figure out why the seo is missing from the context, can anyone please help? Thanks

Edit: I spotted another warning that might be relevant, before the array_merge error:

LOG.warning: trim(): Passing null to parameter #1 ($string) of type string is deprecated in {...}/vendor/statamic/seo-pro/src/Cascade.php on line 353
321zeno commented 1 month ago

I fired up xdebug today and noticed that actually the error comes from here https://github.com/statamic/seo-pro/blob/master/src/Cascade.php#L386 for the $item "{{ git }} add {{ paths }}"

If I comment out the return $this->parseAntlers($raw); here the directive works as expected

duncanmcclean commented 1 month ago

Are you able to provide the full stack trace?