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

[AddLines] Fix update process to send changes to RecipeUpdate vs make them immediately #988

Merged
merged 5 commits into from
Aug 4, 2023

Conversation

weaverryan
Copy link
Member

Hi!

This was an oversight when I create AddLinesConfigurator.

During recipes:update, the purpose of the update() method in each configurator is to record what the "original" contents of a file would look like from the original recipe & what the "new" contents of a file would look like with the new recipe. Then, LATER, the patcher system creates a diff from these.

The AddLinesConfigurator was going rogue and updating the files immediately, which caused the "patcher" system later to explode because this file was unexpectedly already modified.

The changes are less drastic than they look, as code needed to be moved from some public methods -> private methods.

Cheers!

@weaverryan weaverryan changed the base branch from 2.x to 1.x August 2, 2023 14:54
// reset the file content cache
$this->fileContents = [];
$this->executeUnconfigure($recipeUpdate->getOriginalRecipe(), $originalConfig);
$this->executeConfigure($recipeUpdate->getNewRecipe(), $newConfig);
Copy link
Member Author

Choose a reason for hiding this comment

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

The old logic "unconfigured" the original recipe, then configured the new recipe. So we're doing the same, except that we "record" the changes and report them to $recipeUpdate below instead of actually making the changes now.

} catch (ParsingException $e) {
// if controllers.json is invalid (possible during a recipe upgrade), we can't update the file
return;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Unrelated to the PR - but noticed while doing it. We already have this same code in this file to avoid exploding if package.json can't be parsed due to a conflict.

@fabpot
Copy link
Member

fabpot commented Aug 4, 2023

Thank you @weaverryan.

@fabpot fabpot merged commit a2554c7 into symfony:1.x Aug 4, 2023
2 checks passed
@weaverryan weaverryan deleted the add-lines-fix-update branch August 4, 2023 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants