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

Add a check about PS_VERSION_DB #696

Merged

Conversation

Quetzacoalt91
Copy link
Member

@Quetzacoalt91 Quetzacoalt91 commented May 2, 2024

Questions Answers
Description? This PR adds a check on the value of PS_VERSION_DB. A mismatch between the current version of PrestaShop and the value store in database means all the migration files may not have run. The merchant needs to check if its structure is up-to-date by running missed SQL files and bumping PS_VERSION_DB when done.

This PR also removes some duplicated code to get the module version.
Type? improvement
BC breaks? Nope
Deprecations? Nope
Fixed ticket? Partially fixes PrestaShop/PrestaShop#33856, Fixes PrestaShop/PrestaShop#15198
Sponsor company @PrestaShopCorp
How to test? Manually change the value of PS_VERSION_DB in the configuration table to make the error appear. Restoring its original value will make the error disappear.

image

@Quetzacoalt91 Quetzacoalt91 self-assigned this May 2, 2024
@Quetzacoalt91 Quetzacoalt91 force-pushed the add-check-about-PS_VERSION_DB branch from 6e7f870 to 3972539 Compare May 3, 2024 09:01
@Quetzacoalt91 Quetzacoalt91 marked this pull request as ready for review May 3, 2024 09:28
ga-devfront
ga-devfront previously approved these changes May 3, 2024
Copy link
Contributor

@ga-devfront ga-devfront left a comment

Choose a reason for hiding this comment

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

I got just one question about the check condition.

return version_compare(
Configuration::get('PS_VERSION_DB'),
$this->prestashopConfiguration->getPrestaShopVersion(),
'>='
Copy link
Contributor

Choose a reason for hiding this comment

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

why >= and not == ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because if for any reason the version stored in db is above the current PrestaShop, the message displayed asking to run migration files does not make sense. I want to get the message only if the version is below, and "<" is the opposite of ">=".

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed in favor of == following @AureRita checks

M0rgan01
M0rgan01 previously approved these changes May 3, 2024
@AureRita AureRita self-assigned this May 15, 2024
Copy link
Contributor

@AureRita AureRita left a comment

Choose a reason for hiding this comment

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

Hi @Quetzacoalt91

Thank you for your PR, I tested it and it show me correctly the error when I have a previous version on PS_Version_DB and not when I have a newest version as you can see :

recording.203.webm

I tested it on
8.0.5, 8.1.6, 1.7.8.10

I try to do an upgrade from 8.0.5 to 8.1.6 with the major release, all seems ok
but when I try to do an upgrade from 1.7.8.10 to 8.1.6 with the major release, I have this error

image

And when I want to go on the BO :

recording.204.webm

FYI : When I do the upgrade, I put the version 8.1.0 in de PS_Version_DB

Waiting for correction

@Quetzacoalt91 Quetzacoalt91 force-pushed the add-check-about-PS_VERSION_DB branch from 5365ad7 to 10e30e3 Compare May 20, 2024 15:55
Copy link
Contributor

@AureRita AureRita left a comment

Choose a reason for hiding this comment

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

Hi @Quetzacoalt91

Thank you for your PR, I tested it and it seems to works as you can see :

recording.217.webm

Tested on :
1.7.8.11 (major Upgrade to 8.1.6)
8.0.5 (major Upgrade to 8.1.6)
8.1.5 (Minor Upgrade to 8.1.6)
8.1.6

Because the PR seems to works as expected, It's QA ✔️

Thank you

@Quetzacoalt91 Quetzacoalt91 merged commit d4f360b into PrestaShop:dev May 23, 2024
29 checks passed
@Quetzacoalt91 Quetzacoalt91 added this to the 5.0.2 milestone May 23, 2024
@Quetzacoalt91 Quetzacoalt91 deleted the add-check-about-PS_VERSION_DB branch December 20, 2024 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Autoupgrade module runs old sql commands Different store version in the DB and files
6 participants