You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The functionality around the regenerate flag (file `var/.regenerate`) seems broken for some time already. The flag is meant to wipe out generated code (from the `generated/` folder). However, this does not much.
To test for this:
```bash
touch var/.regenerate
mkdir -p generated/code/
touch generated/code/test
```
Expected behaviour: A lock file `var/.regenerate.lock` is generated, the generated code (and specifically, the dummy file `generated/code/test`) is removed and the lock is removed as well, simply by reloading the Magento application (a refresh on the frontend, a call upon `bin/magento`, or something similar) while in the Developer Mode.
Actual behaviour: The `var/.regenerate` just sits there, doing nothing. Likewise, the dummy file `generated/code/test` is still there.
The reason for this is quite simple: Within the main class `\Magento\Framework\Code\GeneratedFiles`, the flag is defined via a constant https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/Code/GeneratedFiles.php#L24 with a value `/var/.regenerate` (an absolute path) and not `var/.regenerate` (a relative path). Because of this, the write call `isExists()` fails validation https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/Code/GeneratedFiles.php#L123 and therefore the flag is never picked up upon.
Changing the constant value to `var/.regenerate` makes sure (on my side) that the generated files are cleaned up properly.
0 commit comments