neos-development-collection icon indicating copy to clipboard operation
neos-development-collection copied to clipboard

BUG: Fusion PartialsCache doesn't flush when developing backend modules

Open Sebobo opened this issue 2 years ago • 4 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current Behavior

I have to run ./flow flow:cache:flushone Neos_Fusion_ParsePartials when changing something in the Fusion part of a backend module to see the update.

Expected Behavior

The cache should be flushed when I change a Fusion file.

Steps To Reproduce

Make a change to one of the Fusion backend modules like the redirect handler UI

Environment

- Flow: 8.x
- Neos: 8.x
- PHP: 8.1

Anything else?

No response

Sebobo avatar Oct 13 '23 09:10 Sebobo

cc @mhsdesign

Sebobo avatar Oct 13 '23 09:10 Sebobo

Yes sadly i experience this issue too.

A workaround for this very second - which of course totally defeats its purpose - is to use a nullbackend or disable the cache

Neos:
  Fusion:
    enableParsePartialsCache: false

i will get on this and debug! Sorry for the inconvenience.

mhsdesign avatar Jan 17 '24 07:01 mhsdesign

We are funny. The file monitor cant flush anything that is not registered for flushing.

I could reproduce this problem with the Flowpack.DecoupledContentStore where the backend module fusion code lives instead of in Resources/Private/Fusion in Resources/Private/BackendFusion. The file monitor for Fusion_Files is only told to detect fusion files beneath Resources/Private/Fusion and lately NodeTypes.

See:

https://github.com/neos/neos-development-collection/blob/43d2f346e6e2cd70df72e5dbabd6ca9496d4cfa1/Neos.Fusion/Classes/Package.php#L50-L58

To fix this and allow packages to freely place their fusion files anywhere beneath Resources/Private we must adjust the monitoring of fusion files to a wider scope.

Im not sure if this is a performance drawback while developing (cc @kitsunet) To reduce overhead we should consider actually only listening for .fusion files instead of all files beneath the directories by leveraging $filenamePattern from monitorDirectory.

mhsdesign avatar Jan 17 '24 16:01 mhsdesign

Seb and me discussed following points:

  • The assumption that all fusion files end with .fusion is correct. We only have to flush for those files and document accordingly that this is the supported usecase.
  • The filemonitor should definitely ignore node_modules https://github.com/neos/flow-development-collection/issues/3266 or have a configuration to ignore certain folder names / files

But to solve the real problem, we either detect all fusion files under Resources/Private https://github.com/neos/neos-development-collection/pull/4840 or we have to find good conventions for folder names. The latter is actually quite hard as over the time each individual seems to have found a custom naming for this BackendModuleFusion folder. But especially that and the current situation screams basically for a convention which will be rewarded by out of the box cache flushing.

Just for reference why another Fusion folder is needed: Due to the auto include pattern of Neos, the root.fusion will be read for frontend rendering. This usually should include a glob for all sub files, in the case there is other fusion code like backend module stuff, it should be excluded. That is often done incorrectly (even in Neos.Neos). To fix this the practice emerged to create a dedicated FusionFolder for other stuff.

In theory, based on the requirements, there could be infinite about of FusionFolders needed if one really wants to seperate every usecase.

An alternative approach would be to move Neos.Neos/Private/Fusion/Root.fusion to Neos.Neos/Private/Fusion/Frontend/Root.fusion and omit the classic Root.fusion directly in the folder. That could be done by allowing to register a custom path in the autoInclude:

Neos:
  Neos:
    fusion:
       autoInclude:
         "Neos.Neos":
             path: resource://Neos.Neos/Private/Fusion/Frontend/Root.fusion

That way everything must be encapsulated in Fusion, like php in Classes.

mhsdesign avatar Feb 13 '24 16:02 mhsdesign