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

Fix upgrade from ps < 1.7.0.0 #22274

Merged
merged 5 commits into from Dec 16, 2020
Merged

Fix upgrade from ps < 1.7.0.0 #22274

merged 5 commits into from Dec 16, 2020

Conversation

atomiix
Copy link
Contributor

@atomiix atomiix commented Dec 7, 2020

Questions Answers
Branch? 1.7.7.x
Description? Because the table ps_tab has been changed on 1.7.7.x, when executing the 1.7.0.0 upgrade script, tabs weren't properly updated. The other issue was that because of a previous upgrade script, the Language class had cache that wasn't up-to-date with the new database structure leading to an SQL update error. This PR fixes both bugs.
Type? bug fix
Category? CO
BC breaks? no
Deprecations? no
Fixed ticket? Fixes #22237 #22294
How to test? Try to upgrade a shop from PrestaShop < 1.7.0.0 (1.6.1.24) to 1.7.7.0, the upgrade process should finish without any error.

This change is Reviewable

@atomiix atomiix requested a review from a team as a code owner December 7, 2020 14:19
@atomiix atomiix added this to the 1.7.7.1 milestone Dec 7, 2020
@prestonBot prestonBot added 1.7.7.x Branch Bug Type: Bug labels Dec 7, 2020
@matks
Copy link
Contributor

matks commented Dec 7, 2020

@atomiix Could it also fix #22250 ?

@atomiix
Copy link
Contributor Author

atomiix commented Dec 7, 2020

@matks I don't think so as #22250 happens from 1.7.6.9 while I'm doing some changes for version < 1.7.0.0

@matks
Copy link
Contributor

matks commented Dec 7, 2020

If I understand correctly,

For PS 1.6 => PS 1.7.6 we have a different structure for tabs (between PS 1.6 and PS 1.7) and the script correctly migrates it
But for PS 1.6 => PS 1.7.7, the file structure is "immediately" migrated to 177 version so the script fails because it expects the old structure

So we have a different script for ps1.6 => ps1.7.6 and ps1.6 => ps1.7.7 ?

@atomiix
Copy link
Contributor Author

atomiix commented Dec 7, 2020

That's the opposite, when upgrading from PS 1.6 to PS 1.7.7, the upgrade script uses core files that expect the new DB structure.

matks
matks previously approved these changes Dec 7, 2020
Copy link
Contributor

@matks matks left a comment

Choose a reason for hiding this comment

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

Code seems OK for me. QA team can validate 1.6 => 1.7 upgrade and automated tests can validate the other paths

Progi1984
Progi1984 previously approved these changes Dec 8, 2020
@Progi1984 Progi1984 added the Waiting for QA Status: action required, waiting for test feedback label Dec 8, 2020
@SD1982 SD1982 self-assigned this Dec 8, 2020
@SD1982
Copy link
Contributor

SD1982 commented Dec 8, 2020

Hi @atomiix The original error is not displayed but I have this error now
I don't know if it's related with your PR because I can really test without
image

[INTERNAL] /var/www/html/builds/1.6.1.24/app/AppKernel.php line 39 - ParseError: syntax error, unexpected ';' #0 /var/www/html/builds/1.6.1.24/modules/autoupgrade/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile('/var/www/html/b...') #1 [internal function]: Composer\Autoload\ClassLoader->loadClass('AppKernel') #2 /var/www/html/builds/1.6.1.24/config/autoload.php(28): spl_autoload_call('AppKernel') #3 /var/www/html/builds/1.6.1.24/modules/autoupgrade/classes/UpgradeContainer.php(545): require_once('/var/www/html/b...') #4 /var/www/html/builds/1.6.1.24/modules/autoupgrade/classes/TaskRunner/Upgrade/UpgradeDb.php(73): PrestaShop\Module\AutoUpgrade\UpgradeContainer->initPrestaShopAutoloader() #5 /var/www/html/builds/1.6.1.24/admin762k5hk9q/autoupgrade/ajax-upgradetab.php(52): PrestaShop\Module\AutoUpgrade\TaskRunner\Upgrade\UpgradeDb->init() #6 {main}

Tested on php7.1 and mysql 5.7

@SD1982 SD1982 added Waiting for author Status: action required, waiting for author feedback Waiting for QA Status: action required, waiting for test feedback and removed Waiting for QA Status: action required, waiting for test feedback labels Dec 8, 2020
@SD1982
Copy link
Contributor

SD1982 commented Dec 9, 2020

Hi @atomiix As we have seen together there is now this error which is displayed:
image

SQL 1.7.7.0 1146 in UPDATE ps_admin_filterSETfilter_id = SUBSTRING(filter_id, 1, 191): Table 'prestashop-161.ps_admin_filter' doesn't exist SQL 1.7.7.0 1146 in ALTER TABLE ps_admin_filterCHANGEfilter_id filter_idVARCHAR(191) NOT NULL: Table 'prestashop-161.ps_admin_filter' doesn't exist SQL 1.7.7.0 1146 in ALTER TABLEps_admin_filterCONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci: Table 'prestashop-161.ps_admin_filter' doesn't exist SQL 1.7.7.0 1146 in ALTER TABLEps_link_blockCONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci: Table 'prestashop-161.ps_link_block' doesn't exist SQL 1.7.7.0 1146 in ALTER TABLEps_link_block_langCONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci: Table 'prestashop-161.ps_link_block_lang' doesn't exist SQL 1.7.7.0 1146 in ALTER TABLEps_link_block_shopCONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci: Table 'prestashop-161.ps_link_block_shop' doesn't exist SQL 1.7.7.0 1146 in ALTER TABLEps_module_historyCONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci: Table 'prestashop-161.ps_module_history' doesn't exist SQL 1.7.7.0 1146 in ALTER TABLEps_translation CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci: Table 'prestashop-161.ps_translation' doesn't exist

@SD1982 SD1982 added Waiting for dev Status: action required, waiting for tech feedback and removed Waiting for QA Status: action required, waiting for test feedback Waiting for author Status: action required, waiting for author feedback labels Dec 9, 2020
@atomiix atomiix removed the Waiting for dev Status: action required, waiting for tech feedback label Dec 9, 2020
Copy link
Contributor

@Progi1984 Progi1984 left a comment

Choose a reason for hiding this comment

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

Some feedback

Co-authored-by: Progi1984 <progi1984@gmail.com>
Progi1984
Progi1984 previously approved these changes Dec 14, 2020
Copy link
Contributor

@jolelievre jolelievre left a comment

Choose a reason for hiding this comment

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

Not sure about the last comment so I still approve I let you judge if the modif is required or not

@atomiix atomiix added the Waiting for QA Status: action required, waiting for test feedback label Dec 16, 2020
@SD1982
Copy link
Contributor

SD1982 commented Dec 16, 2020

LGTM now !! No errors displayed during the upgrade process !!
upgraded from 1.6.1.24
php 7.1
mysql 5.7
Thanks @atomiix !!

@SD1982 SD1982 added QA ✔️ Status: check done, code approved and removed Waiting for QA Status: action required, waiting for test feedback labels Dec 16, 2020
@atomiix atomiix merged commit 5aebd3c into PrestaShop:1.7.7.x Dec 16, 2020
@atomiix atomiix deleted the fix/22237 branch December 16, 2020 15:28
@gyan111
Copy link

gyan111 commented Dec 19, 2020

When will this available on autoupgrade?

@matks
Copy link
Contributor

matks commented Dec 19, 2020

@gyan111 This PR has been milestoned for PS 1.7.7.1 which is scheduled for mid January 2021 or late January 2021.

@mbautista
Copy link

mbautista commented Apr 5, 2022

Hello,
I try to upgrade from PS 1.6.0.11 to PS 1.7.8.5 and I have this error :

# /usr/bin/php7.1 install/upgrade/upgrade.php
PHP Warning:  Invalid argument supplied for foreach() in /***/classes/Profile.php on line 251
PHP Fatal error:  Uncaught PrestaShopObjectNotFoundException: The hook id #0 does not exist in database in /***/classes/Hook.php:242
Stack trace:
#0 /***/classes/Hook.php(677): HookCore::getNameById(0)
#1 /***/classes/module/Module.php(1029): HookCore::unregisterHook(Object(BlockSearch), 0, NULL)
#2 /***/classes/module/Module.php(733): ModuleCore->unregisterHook(0)
#3 /***/src/Adapter/Module/Module.php(269): ModuleCore->uninstall()
#4 /***/src/PrestaShopBundle/Install/Upgrade.php(565): PrestaShop\PrestaShop\Adapter\Module\Module->onUninstall()
#5 /***/src/PrestaShopBundle/Install/Upgrade.php(820): PrestaShopBundle\Install\Upgrade->disableIncompatibleModules()
#6 /***/install/upgrade/upgrade.php(93): PrestaShopBundle\Install\Upgrade->run()
#7 {main}
  thrown in /***/classes/Hook.php on line 242

Is there any solution for this ?
Thank you very much :)

EDIT : I found a simple hack : juste add the following line in classes/Hook.php before line 234 (beginning of the getNameById function) :
if ($hook_id == 0) return null;
I had another problem with the paypal module, I renamed the folder and the upgrade script could complete without any further error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.7.7.x Branch Bug Type: Bug QA ✔️ Status: check done, code approved
Projects
None yet
10 participants