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

Sitemap detail cache issue #14

Closed
jlachancekffein opened this issue Oct 30, 2019 · 1 comment
Closed

Sitemap detail cache issue #14

jlachancekffein opened this issue Oct 30, 2019 · 1 comment

Comments

@jlachancekffein
Copy link

Hi,

I think we found a bug related to the sitemap detail URLs.

The listing display works correctly. However, the detail of a sitemap URL always returns the first cached result.

In SitemapController.php the actionDetail call the SeoFields::$plugin->sitemapSerivce->getSitemapData service method. You got a typo in sitemapSerivce :)

Inside getSitemapData() method :

if (!Craft::$app->getConfig()->general->devMode) {

            $data = Craft::$app->getCache()->getOrSet(
                '',
                function () use ($data, $type, $settings, $sectionId) {
                    return $this->_addElementsToSitemap($data, $settings[$type][$sectionId]);
                },
                null,
                $cacheDependency
            );
        } else {
            $data = $this->_addElementsToSitemap($data, $settings[$type][$sectionId]);
        }

It's working great locally cause I'm in devmode. But not in the stating and prod environment.

I think the problem is the empty cache_key.

So, if a request /sitemap_1_entry_5_aluminium_single.xml it's working great. But if I request /sitemap_1_entry_4_about_single.xml, I got the same result as the first request url call.

I fix it by removing the condition Craft::$app->getConfig()->general->devMode directly in the vendor code. But it's not a good solution.

I think the solution is to use a valid cache_key. ex : self::SITEMAP_CACHE_KEY . "" . $siteId . "" . $sectionId.

Thank you !

@janhenckens
Copy link
Member

Thanks for reporting the issue! Fix should be out shortly :)

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