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

Updater Suggestions #889

Open
wrossmann opened this issue May 9, 2023 · 2 comments
Open

Updater Suggestions #889

wrossmann opened this issue May 9, 2023 · 2 comments

Comments

@wrossmann
Copy link
Contributor

wrossmann commented May 9, 2023

Was just helping a friend through a failed update to 1.7.0 and have some notes for the updater logic.

  1. Your database migrations are fragile and one-way.
    • The migrations are not completely idempotent [Eg: 112, which is what we fought with] and there is no rollback code at all, meaning that a single failed statement can leave the DB in a state that requires either manual intervention or a restore from backup.
    • My knee-jerk reaction was "use transactions" but you can't do DML modifications in a transaction.
    • I would suggest using a library that specifically handles DB migrations and regressions, eg: up() and down().
  2. The updater does not update the app version until all migrations have run, meaning that re-running updater tries to apply all the migrations again.
    • After each migration is run either update the config.version to match, or use a separate version setting just for the migrations.
    • This would allow migrations to be resumed after fixing specific issues, without re-running potentially non-idempotent migrations.
  3. $this->latestVersion = array_pop(array_keys($this->updateList));
    • To get rid of the notice 'Only variables should be passed by reference':
      array_pop(array_keys($this->updateList)) -> array_slice(array_keys($this->updateList), -1)[0]

Specifically what I think happened is $friend started at config.version == 1 and got up to 355 where a duplicate mod entry caused the whole thing to conk out, and then he got stuck at the noted migration for 112. Since the DB structure was already obviously changed we commented out the block. After seeing the duplicate key failure in 355 we reviewed the tables that appear to reference sb_mods, sb_servers and sb_submissions, and removed the duplicate entry that was not referenced.

@dhopeross
Copy link

And maybe don't put your PHP closing bracket before the secret code so IT'S NOT BEING BLASTED OUT TO THE ENTIRE INTERNET!!!!

@wrossmann
Copy link
Contributor Author

Haha yeah. I think that the upgrade script might just append the define() statement to the settings file without checking if there's a closing ?> at the end.

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

No branches or pull requests

2 participants