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

Fix non-working regenerate flag #39140

Open
wants to merge 5 commits into
base: 2.4-develop
Choose a base branch
from

Conversation

jissereitsma
Copy link
Contributor

@jissereitsma jissereitsma commented Sep 4, 2024

Description (*)

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.

Manual testing scenarios (*)

To test for this:

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.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

Resolved issues:

  1. resolves [Issue] Fix non-working regenerate flag #39152: Fix non-working regenerate flag

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.
Copy link

m2-assistant bot commented Sep 4, 2024

Hi @jissereitsma. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.

Add the comment under your pull request to deploy test or vanilla Magento instance:
  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@engcom-Hotel
Copy link
Contributor

@magento create issue

@engcom-Hotel engcom-Hotel added the Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. label Sep 10, 2024
@Priyakshic Priyakshic added the Project: Community Picked PRs upvoted by the community label Sep 12, 2024
@engcom-Hotel
Copy link
Contributor

@magento run all tests

@engcom-Hotel engcom-Hotel added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Sep 13, 2024
Copy link
Contributor

@engcom-Hotel engcom-Hotel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @jissereitsma,

Thanks for the report and collaboration!

The changes seems good to me, but there are some static tests failures. Please fix them.

Thanks

@engcom-Dash
Copy link

@magento run all tests

@engcom-Charlie
Copy link
Contributor

It seems that the review changes mentioned in comment, has been taken care hence moving it back to review.

@engcom-Dash
Copy link

Hello @jissereitsma ,

Thanks for your contribution!

As per this comment, the issue is not reproducible. I also tried but was unable to reproduce it.

Could you please recheck or provide more details?

Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: needs update Project: Community Picked PRs upvoted by the community Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
Status: On Hold
Development

Successfully merging this pull request may close these issues.

[Issue] Fix non-working regenerate flag
5 participants