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

Simplify autogenerated boilerplate upgrader class #22225

Merged
merged 2 commits into from
Dec 11, 2021

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented Dec 8, 2021

Overview

De-clutters our autogenerated upgrader classes.

Before

Every month we autogenerate a file full of unnecessary boilerplate.

After

Simpler

@civibot
Copy link

civibot bot commented Dec 8, 2021

(Standard links)

@civibot civibot bot added the master label Dec 8, 2021
@colemanw
Copy link
Member Author

colemanw commented Dec 8, 2021

@totten I can't remember how to actually run this. Can you please r-run?

@totten
Copy link
Member

totten commented Dec 9, 2021

It's generated by set-version.php whenever we bump up the middle number. If the current version is 5.46.alpha1, then you can bump up to 5.47.alpha1.

git scan am -N https://github.com/civicrm/civicrm-core/pull/22225
./tools/bin/scripts/set-version.php 5.47.alpha1 --no-commit
cv upgrade:db -vv

I can confirm that the above procedure still appears OK.

On the general merits... I am concerned that the signatures/lifecycles for the methods in CRM/Upgrade/Incremental/php/* are weird. One's gut sense for how to write these methods is often wrong/problematic. Not so weird as to confuse most readers when skimming existing methods -- but weird enough that it's very easy to get wrong when writing afresh.

OTOH, I think your point here is good wrt readers and overall readability - eg looking back over a list of 40+ of these classes, all the comments make it harder to focus-in on the things which are distinctive.

The concerns about writing could perhaps be mitigated by improving the docblocks in the base-class to include or link-to examples.

@colemanw
Copy link
Member Author

colemanw commented Dec 10, 2021

Thanks. I was able to run it myself following that tip.

On the general merits... I am concerned that the signatures/lifecycles for the methods in CRM/Upgrade/Incremental/php/* are weird. One's gut sense for how to write these methods is often wrong/problematic. Not so weird as to confuse most readers when skimming existing methods -- but weird enough that it's very easy to get wrong when writing afresh.

Yea the upgrade classes are still a bit screwy.

OTOH, I think your point here is good wrt readers and overall readability - eg looking back over a list of 40+ of these classes, all the comments make it harder to focus-in on the things which are distinctive.

Not anymore! #22226 +86 −1,830!

The concerns about writing could perhaps be mitigated by improving the docblocks in the base-class to include or link-to examples.

I think the biggest gotcha is in the comment * Important! All upgrade functions MUST add a 'runSql' task. - that is indeed important but the previous boilerplate was messy-looking and kind of expected the comment to be deleted after being read, which was an invitation for merge-conflicts. I've reworked that into a docblock at the top of the class which is neater.

@demeritcowboy
Copy link
Contributor

demeritcowboy commented Dec 10, 2021

The if ($rev == part is also important, otherwise the pre/post message repeats (at least) 3 times (alpha/beta/.0), but not a blocker. It's inconsistent with the convention of upgrade_X function names having the version in the function name, so maybe one future approach would be to make that consistent, i.e. setPreUpgradeMessage_5.5.alpha1

@totten
Copy link
Member

totten commented Dec 10, 2021

OTOH, I think your point here is good wrt readers and overall readability - eg looking back over a list of 40+ of these classes, all the comments make it harder to focus-in on the things which are distinctive.

(@colemanw) Not anymore! #22226 +86 −1,830!

😃

(@colemanw) I think the biggest gotcha is in the comment * Important! All upgrade functions MUST add a 'runSql' task.

(@demeritcowboy) The if ($rev == part is also important, otherwise the pre/post message repeats (at least) 3 times (alpha/beta/.0)...

Exactly.

I've pushed up some docblocks to replace the examples.

I'm OK with merge-on-pass here.

@totten totten added the merge ready PR will be merged after a few days if there are no objections label Dec 10, 2021
@totten totten merged commit 0653639 into civicrm:master Dec 11, 2021
@totten totten deleted the upgradeTemplateFix branch December 11, 2021 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
master merge ready PR will be merged after a few days if there are no objections
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants