Skip to content

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

Merged
fabpot merged 5 commits intosymfony:1.xfrom
weaverryan:add-lines-fix-update
Aug 4, 2023
Merged

[AddLines] Fix update process to send changes to RecipeUpdate vs make them immediately#988
fabpot merged 5 commits intosymfony:1.xfrom
weaverryan:add-lines-fix-update

Conversation

@weaverryan
Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor 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
Copy Markdown
Contributor 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
Copy Markdown
Member

fabpot commented Aug 4, 2023

Thank you @weaverryan.

@fabpot fabpot merged commit a2554c7 into symfony:1.x Aug 4, 2023
@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