getgrav / grav-premium-issues

Official Grav Premium Issues repository to report problems or ask questions regarding the Premium products offered.
https://getgrav.org/premium
7 stars 2 forks source link

[warm-cache] sitemap.json error #102

Closed replayshot closed 3 years ago

replayshot commented 3 years ago

After installing the plugin via admin, my admin console showed 404 error and it said something about sitemap.json.

I refreshed the page and everything was fine. Then I thought I'd test it, so I cleared the cache via CLI bin/grav cache and then I received the following error:

In ResponseTrait.php line 149:

Syntax error for "https://mydomain.com/sitemap.json".

I do have sitemap plugin enabled. Why does it throw this .json error if my sitemap is under sitemap.xml

if I got to mydomain.com/sitemap.json url - it says:

{"version":"https:\/\/jsonfeed.org\/version\/1","title":null,"home_page_url":"https:\/\/mydomain.com\/","feed_url":"https:\/\/mydomain.com\/sitemap.json","description":null,"author":{"name":"company"},"items":[]}

also, this is a bit of a side question, but how do I tell the plugin is working?

rhukster commented 3 years ago

Do you have the latest version of sitemap plugin installed?

replayshot commented 3 years ago

good question. I think so: v3.0.1 Grav v1.7.15 - Admin v1.10.15

rhukster commented 3 years ago

Is it possible to get the link to your actual sitemap json?

replayshot commented 3 years ago

sure: https://googleslidesthemes.com/sitemap.json

rhukster commented 3 years ago

Do you happen to have a custom sitemap.json.twig file in your theme or something? There’s not much to the one provided by sitemap plugin but your output is escaped strangely, so I’m not sure if it’s using the built in one. If you are not then perhaps it’s some twig setting you have made in your system config of Grav?

replayshot commented 3 years ago

No, I do not have a custom sitemap.json.twig in my templates/partials directory of my theme, so it is using the buil in one. The plugin has this inside it: {{ (sort_sitemap_entries_by_language()|json_encode|raw) }}

I was disabling different plugins and it appears that if I disable the Feed plugin v1.8.0 ( https://github.com/getgrav/grav-plugin-feed ) the sitemap.json shows up fine. Could this be related to this: https://github.com/trilbymedia/grav-plugin-image-captions/issues/17

I now see entries in the Logs of pages being warmed up.

rhukster commented 3 years ago

I'm a bit confused about how image-captions bug could be related to feed plugin which in turn relates to sitemap plugin :)

On my local I have the latest feed version enabled and it doesn't impact the json, all looks fine. I did have one minor local change that i've now pushed as part of feed v1.8.1. I don't think this should be the issue, but it might be worth upgrading that when it shows up in GPM.

I also have image-captions installed and enabled, and that is not impacting the sitemap json either.

I did just check your JSON again and it does look fine. Can you confirm that enabling feed is what's breaking it for you?

replayshot commented 3 years ago

I am not sure if it has anything to do with it (just there was an issue with a broken feed because of the image caption), so I just threw it out there for you if it would help.

I confirm that when I enable the feed (I will leave it enabled now, you can find it under googleslidesthemes.com/.rss), it breaks the sitemap.json. In the log I get the following:

/opt/bitnami/apps/preso/htdocs/user/plugins/warm-cache/warm-cache.php(173): Symfony\Component\HttpClient\Response\CurlResponse->toArray() /opt/bitnami/apps/preso/htdocs/user/plugins/warm-cache/warm-cache.php(75): Grav\Plugin\WarmCachePlugin::warmCache() /opt/bitnami/apps/preso/htdocs/vendor/symfony/event-dispatcher/EventDispatcher.php(264): Grav\Plugin\WarmCachePlugin->onAfterCacheClear(Object(RocketTheme\Toolbox\Event\Event), 'onAfterCacheCle...', Object(Symfony\Component\EventDispatcher\EventDispatcher)) /opt/bitnami/apps/preso/htdocs/vendor/symfony/event-dispatcher/EventDispatcher.php(239): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'onAfterCacheCle...', Object(RocketTheme\Toolbox\Event\Event)) /opt/bitnami/apps/preso/htdocs/vendor/symfony/event-dispatcher/EventDispatcher.php(73): Symfony\Component\EventDispatcher\EventDispatcher->callListeners(Array, 'onAfterCacheCle...', Object(RocketTheme\Toolbox\Event\Event)) /opt/bitnami/apps/preso/htdocs/system/src/Grav/Common/Grav.php(556): Symfony\Component\EventDispatcher\EventDispatcher->dispatch(Object(RocketTheme\Toolbox\Event\Event), 'onAfterCacheCle...') /opt/bitnami/apps/preso/htdocs/system/src/Grav/Common/Cache.php(535): Grav\Common\Grav->fireEvent('onAfterCacheCle...', Object(RocketTheme\Toolbox\Event\Event)) /opt/bitnami/apps/preso/htdocs/user/plugins/admin/classes/plugin/AdminController.php(632): Grav\Common\Cache::clearCache('invalidate') /opt/bitnami/apps/preso/htdocs/user/plugins/admin/classes/plugin/AdminBaseController.php(127): Grav\Plugin\Admin\AdminController->taskEnable() /opt/bitnami/apps/preso/htdocs/user/plugins/admin/admin.php(1005): Grav\Plugin\Admin\AdminBaseController->execute()

rhukster commented 3 years ago

In the feed plugin configuration can you disable JSON?

enable_json_feed: false
rhukster commented 3 years ago

I've confirmed that's the issue, just looking for the best solution.

rhukster commented 3 years ago

Ok, i've released a 1.8.2 version of feed that ensures its only takes over .json requests when it's on a valid page with a valid collection. Seems it was hijacking any JSON request and sending it through the json feed template. JSON feeds are disabled by default which is why I had never noticed it before. JSON feed was broken in 1.7 too, so fixed that while I was at it.

replayshot commented 3 years ago

Great stuff. Thanks a lot of your help. I can confirm that disabling that option does fix the issue.