statamic / ssg

The official Statamic Static Site Generator
230 stars 23 forks source link

Multiple blueprints use using the same template with different fieds leak data #37

Closed RussBrown00 closed 3 years ago

RussBrown00 commented 3 years ago

If multiple blueprints use the same template but don't have all the same fields, it is possible for data from one collection to leak into another.

The result of this for me was data from one page showing up on another.

The temp patch was to cross-add the missing types to the inverse pages and my problem was fixed

tao commented 3 years ago

So this might be related to this problem I was having on #15?

padders commented 3 years ago

I think we have this issue too, we have a topics page that shows 3 different kinds of posts that get completely messed up when run through the ssg.

tao commented 3 years ago

The same issue appears when using yield sections in the antlers layouts. If the yield is not used it generates the page with data from another collection item or page that did use this yield section.

tao commented 3 years ago

I've created an example repo to test this issue. If you open up the website normally it works fine:

Screenshot 2020-12-30 at 22 41 45

Screenshot 2020-12-30 at 22 43 37

Once you generate the static website you can see each page shows data is leaking in different ways. On Page Two, the header leaks through the yield:header in the layout.

Screenshot 2020-12-30 at 22 41 49

While the test and 404 pages have data leaking from the blueprint where a field called extra is defined but null on these pages.

Screenshot 2020-12-30 at 22 41 52 Screenshot 2020-12-30 at 22 41 55

I have tried to debug and find a solution to this myself but I've had no luck yet. My best guess is that when SSG calls the Cascade, it fetches an instance. The Cascade uses get and set methods to store data but the older fields are not cleared when the entry or blueprint changes? As SSG runs in one process, the Cascade instance is not cleared between page renders, while if you fetch the page from the browser it creates a new instance of the Laravel app on each request?

rustypaul commented 3 years ago

Is there any update on whether this might be fixed soon? This is actively preventing us using Statamic currently when we desperately want to, especially now it has graphql coming.

tao commented 3 years ago

I had an email conversation with @jackmcdade in the beginning of January and he mentioned getting 3.1 shipped and these SSG issues were a high priority but I don't believe there's been any further updates on SSG since then. I'm sure it'll be looked at soon.