Skip to content

Commit 6c8f11f

Browse files
authored
Update GeneratedFiles.php
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.
1 parent 672a2e6 commit 6c8f11f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/internal/Magento/Framework/Code/GeneratedFiles.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class GeneratedFiles
2121
/**
2222
* Regenerate flag file name
2323
*/
24-
const REGENERATE_FLAG = '/var/.regenerate';
24+
const REGENERATE_FLAG = 'var/.regenerate';
2525

2626
/**
2727
* Regenerate lock file name

0 commit comments

Comments
 (0)