Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[warm-cache] sitemap.json error #102

Closed
replayshot opened this issue May 20, 2021 · 12 comments
Closed

[warm-cache] sitemap.json error #102

replayshot opened this issue May 20, 2021 · 12 comments
Assignees

Comments

@replayshot
Copy link

replayshot commented May 20, 2021

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
Copy link
Member

Do you have the latest version of sitemap plugin installed?

@replayshot
Copy link
Author

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

@rhukster
Copy link
Member

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

@replayshot
Copy link
Author

@rhukster
Copy link
Member

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?

@rhukster rhukster self-assigned this May 21, 2021
@replayshot
Copy link
Author

replayshot commented May 21, 2021

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: trilbymedia/grav-plugin-image-captions#17

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

@rhukster
Copy link
Member

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
Copy link
Author

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
Copy link
Member

In the feed plugin configuration can you disable JSON?

enable_json_feed: false

@rhukster
Copy link
Member

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

@rhukster
Copy link
Member

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
Copy link
Author

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

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

No branches or pull requests

2 participants