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

Migration error during upgrade from < 3.2.0 with PHP 8.1 #8284

Closed
Vitaliy-1 opened this issue Sep 22, 2022 · 4 comments
Closed

Migration error during upgrade from < 3.2.0 with PHP 8.1 #8284

Vitaliy-1 opened this issue Sep 22, 2022 · 4 comments
Assignees
Labels
Bug:1:Low A bug that does not have a severe consequence or affects a small number of users.
Milestone

Comments

@Vitaliy-1
Copy link
Collaborator

Describe the bug
I am receiving a fatal error during the migration of OJS with versions below 3.2.0 to the current main with PHP8.1:

[pre-install]
[load: upgrade.xml]
[version: 3.4.0.0]
[code: Installer Installer::checkPhpVersion]
[code: Installer Installer::migrateSubmissionCoverImages]
[data: dbscripts/xml/upgrade/3.2.0_preupdate_email_templates.xml]
[data: dbscripts/xml/upgrade/3.2.0_preupdate_versioning_articleGalleySettings.xml (skipped)]
[data: dbscripts/xml/upgrade/3.2.0_preupdate_versioning.xml]
[data: dbscripts/xml/upgrade/3.2.0_preupdate_last_activity.xml]
[schema: lib/pkp/xml/schema/common.xml]
PHP Fatal error:  Uncaught mysqli_sql_exception: Table 'cypress-stable.email_templates_settings' doesn't exist in /home/doc/OJS/development/ojs/lib/pkp/lib/vendor/adodb/adodb-php/drivers/adodb-mysqli.inc.php:788
Stack trace:
#0 /home/doc/OJS/development/ojs/lib/pkp/lib/vendor/adodb/adodb-php/drivers/adodb-mysqli.inc.php(788): mysqli_query()
#1 /home/doc/OJS/development/ojs/lib/pkp/lib/vendor/adodb/adodb-php/adodb.inc.php(1263): ADODB_mysqli->_query()
#2 /home/doc/OJS/development/ojs/lib/pkp/lib/vendor/adodb/adodb-php/adodb.inc.php(1241): ADOConnection->_Execute()
#3 /home/doc/OJS/development/ojs/lib/pkp/lib/vendor/adodb/adodb-php/drivers/adodb-mysqli.inc.php(348): ADOConnection->Execute()
#4 /home/doc/OJS/development/ojs/lib/pkp/lib/vendor/adodb/adodb-php/adodb-datadict.inc.php(217): ADODB_mysqli->MetaIndexes()
#5 /home/doc/OJS/development/ojs/lib/pkp/lib/vendor/adodb/adodb-php/adodb-xmlschema.inc.php(484): ADODB_DataDict->MetaIndexes()
#6 /home/doc/OJS/development/ojs/lib/pkp/lib/vendor/adodb/adodb-php/adodb-xmlschema.inc.php(349): dbTable->create()
#7 [internal function]: dbTable->_tag_close()
#8 /home/doc/OJS/development/ojs/lib/pkp/lib/vendor/adodb/adodb-php/adodb-xmlschema.inc.php(1508): xml_parse()
#9 /home/doc/OJS/development/ojs/lib/pkp/lib/vendor/adodb/adodb-php/adodb-xmlschema.inc.php(1421): adoSchema->ParseSchemaString()
#10 /home/doc/OJS/development/ojs/lib/pkp/classes/install/Installer.php(408): adoSchema->ParseSchema()
#11 /home/doc/OJS/development/ojs/lib/pkp/classes/install/Installer.php(286): PKP\install\Installer->executeAction()
#12 /home/doc/OJS/development/ojs/lib/pkp/classes/install/Installer.php(201): PKP\install\Installer->executeInstaller()
#13 /home/doc/OJS/development/ojs/lib/pkp/classes/cliTool/UpgradeTool.php(95): PKP\install\Installer->execute()
#14 /home/doc/OJS/development/ojs/lib/pkp/classes/cliTool/UpgradeTool.php(68): PKP\cliTool\UpgradeTool->upgrade()
#15 /home/doc/OJS/development/ojs/tools/upgrade.php(21): PKP\cliTool\UpgradeTool->execute()
#16 {main}
  thrown in /home/doc/OJS/development/ojs/lib/pkp/lib/vendor/adodb/adodb-php/drivers/adodb-mysqli.inc.php on line 788

To Reproduce
Steps to reproduce the behavior:

  1. Install OJS stable 3.1.2 version
  2. Prepare for upgrade
  3. Run migration from CLI: php8.1 tools/upgrade.php upgrade
  4. See error

What application are you using?
upgrade from OJS stable-3_1_2 to main

Additional information
Looks like a failure to create a new table when syncing with the schema.

@Vitaliy-1 Vitaliy-1 added the Bug:1:Low A bug that does not have a severe consequence or affects a small number of users. label Sep 22, 2022
@Vitaliy-1 Vitaliy-1 added this to the 3.4 milestone Sep 22, 2022
@asmecher
Copy link
Member

Ah, this appears to specifically affect 3.1.2. There is automated test coverage for upgrades from older (3.1.1-2) and newer (3.2.x) upgrades, but not 3.1.2; I've duplicated the issue locally with a test dataset from that version. I'll see if I can track this down and also add automated upgrade testing for 3.1.2.

@asmecher asmecher self-assigned this Sep 22, 2022
asmecher added a commit to pkp/ojs that referenced this issue Sep 23, 2022
@asmecher
Copy link
Member

This appears to be an ADODB problem with a recent-ish change to mysqli error handling -- potentially fixed with newer ADODBs, but I wasn't able to find it. Previously, the XMLSchema toolset would look for existing indexes and columns on a table without regard for whether or not that table existed. If it didn't, there would be a MySQL error generated, and a false return value from the MetaIndexes and MetaColumns calls would be interpreted by XMLSchema to mean the table didn't exist. Recently, though, calling MetaIndexes and MetaColumns on a non-existent table (rightly) generates a SQL error that ADODB does not handle.

I worked around this by checking for table existence before calling MetaIndexes or MetaColumns during schema XML parsing. It's a quick-and-dirty workaround but this is a legacy section of code so I don't mind. This is added as another vendor patch to ADODB.

I have also added a 3.1.2 test dataset from my personal collection and will see if I can get automated upgrade testing working with that.

@asmecher
Copy link
Member

Tests passed -- committed to main. But I think I'll also back-port this to stable-3_3_0, since it's not otherwise invasive.

@asmecher asmecher modified the milestones: 3.4, 3.3.0-13 Sep 23, 2022
asmecher added a commit that referenced this issue Sep 23, 2022
@asmecher
Copy link
Member

Back-ported to stable-3_3_0 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug:1:Low A bug that does not have a severe consequence or affects a small number of users.
Projects
None yet
Development

No branches or pull requests

3 participants