OJS - Error during upgrade from 3.2.1.4 to 3.3.0.11 - Duplicate entry plugins.blocks-browse-1-0-1-0 for key versions_pkey

Describe the issue or problem
Hi,
I’m having problem when try to upgrade OJS from 3.2.1-4 to 3.3.0-11.
The upgrade stopped and shows fatal error of duplicate entry, but i don’t know that the duplicate is. seem’s like problem with one of the plugin but i don’t get any clue furthermore to resolve it.

Steps I took leading up to the issue:
Upgrade OJS from terminal using php 7.3.24

What I tried to resolve the issue:
-Remove all custom blockplugins from OJS 3.2.1-4 UI, but still not solved.
-Remove some dangling plugins (they’re not displayed on any journal, but exist on database) from phpmyadmin, but still not solved.

Application Version:
OJS 3.2.1-4 (Current)
OJS 3.3.0.11 (Target upgrade version)

Upgrade log displayed below:

user@laptop ~ % /Applications/MAMP/bin/php/php7.3.24/bin/php /Applications/MAMP/htdocs/myojs/tools/upgrade.php upgrade                                       
2022-07-11 00:25:40 [pre-install]
2022-07-11 00:25:40 [load: upgrade.xml]
2022-07-11 00:25:40 [version: 3.3.0.11]
2022-07-11 00:25:40 [code: Installer Installer::checkPhpVersion]
2022-07-11 00:25:40 [code: Installer Installer::installDefaultNavigationMenus]
2022-07-11 00:25:40 [code: Installer Installer::migrateStaticPagesToNavigationMenuItems]
2022-07-11 00:25:40 [migration: PKPv3_3_0UpgradeMigration]

Notice: unserialize(): Error at offset 28 of 51 bytes in /Applications/MAMP/htdocs/myojs/lib/pkp/classes/migration/upgrade/PKPv3_3_0UpgradeMigration.inc.php on line 625

Warning: Invalid argument supplied for foreach() in /Applications/MAMP/htdocs/myojs/lib/pkp/classes/migration/upgrade/PKPv3_3_0UpgradeMigration.inc.php on line 626

Notice: unserialize(): Error at offset 36 of 37 bytes in /Applications/MAMP/htdocs/myojs/lib/pkp/classes/migration/upgrade/PKPv3_3_0UpgradeMigration.inc.php on line 625

Warning: Invalid argument supplied for foreach() in /Applications/MAMP/htdocs/myojs/lib/pkp/classes/migration/upgrade/PKPv3_3_0UpgradeMigration.inc.php on line 626

Notice: unserialize(): Error at offset 28 of 51 bytes in /Applications/MAMP/htdocs/myojs/lib/pkp/classes/migration/upgrade/PKPv3_3_0UpgradeMigration.inc.php on line 666

Warning: Invalid argument supplied for foreach() in /Applications/MAMP/htdocs/myojs/lib/pkp/classes/migration/upgrade/PKPv3_3_0UpgradeMigration.inc.php on line 667

Notice: unserialize(): Error at offset 36 of 37 bytes in /Applications/MAMP/htdocs/myojs/lib/pkp/classes/migration/upgrade/PKPv3_3_0UpgradeMigration.inc.php on line 666

Warning: Invalid argument supplied for foreach() in /Applications/MAMP/htdocs/myojs/lib/pkp/classes/migration/upgrade/PKPv3_3_0UpgradeMigration.inc.php on line 667
2022-07-11 00:26:03 [migration: OJSv3_3_0UpgradeMigration]
2022-07-11 00:26:03 [note: docs/release-notes/README-3.3.0]
2022-07-11 00:26:03 [code: Installer Installer::addPluginVersions]

Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'plugins.blocks-browse-1-0-1-0' for key 'versions_pkey' in /Applications/MAMP/htdocs/myojs/lib/pkp/lib/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:115
Stack trace:
#0 /Applications/MAMP/htdocs/myojs/lib/pkp/lib/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php(115): PDOStatement->execute(NULL)
#1 /Applications/MAMP/htdocs/myojs/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(489): Doctrine\DBAL\Driver\PDOStatement->execute()
#2 /Applications/MAMP/htdocs/myojs/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(664): Illuminate\Database\Connection->Illuminate\Database\{closure}('INSERT INTO ver...', Array)
#3 /Applications/MAMP/htdocs/myojs/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(631): Illuminate\Database\Connection->runQueryCallback('INSERT INTO ver...', Array, Object(Closure))
#4 /Applications/ in /Applications/MAMP/htdocs/myojs/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 671

Any help will be appreciated.
Best regard.

Finally I have solved the problem.
What I tried to resolve the issue:
I dug more about related upgrade script and look at unserialize(): error message

/Applications/MAMP/htdocs/myojs/lib/pkp/classes/migration/upgrade/PKPv3_3_0UpgradeMigration.inc.php on line 625

I found that the private function on line 618 and was made to fix the capital of custom block title into lowercase. I decided to delete all of the custom block plugins created before, including the dangled custom block plugin from plugin-settings table.

Next, i focused on this line
2022-07-11 00:26:03 [code: Installer Installer::addPluginVersions]
It seems related to this script:
lib/pkp/classes/install/Installer.inc.php
that contain:

	function addPluginVersions() {
		$versionDao = DAORegistry::getDAO('VersionDAO'); /* @var $versionDao VersionDAO */
		import('lib.pkp.classes.site.VersionCheck');
		$fileManager = new FileManager();
		$categories = PluginRegistry::getCategories();
		foreach ($categories as $category) {
			PluginRegistry::loadCategory($category);
			$plugins = PluginRegistry::getPlugins($category);
			if (!empty($plugins)) {
				foreach ($plugins as $plugin) {
					$versionFile = $plugin->getPluginPath() . '/version.xml';

					if ($fileManager->fileExists($versionFile)) {
						$versionInfo = VersionCheck::parseVersionXML($versionFile);
						$pluginVersion = $versionInfo['version'];
					} else {
						$pluginVersion = new Version(
							1, 0, 0, 0, // Major, minor, revision, build
							Core::getCurrentDate(), // Date installed
							1,	// Current
							'plugins.'.$category, // Type
							basename($plugin->getPluginPath()), // Product
							'',	// Class name
							0,	// Lazy load
							$plugin->isSitePlugin()	// Site wide
						);
					}
					$versionDao->insertVersion($pluginVersion, true);
				}
			}
		}

		return true;
	}

I think the script above was intended to copy the version number from each version.xml file, from myojs/plugins/ folder into versions table on ojs database. However, several exact same versions number of identical plugins were existed in versions table. That’s why when the script above try to insert(copy) the plugin version number to versions table, it shows the duplicate entry error message instead.

At this point, i decided to remove all of the rows that contained with version number which has closest date_installed value to today(July 11 2022), except the product_type = core. The image below shows that on July 10 2022 i have several version number.
Screen Shot 2022-07-11 at 12.48.25
After delete all the red boxed value from versions table, the upgrade process succeeded and all of the plugins also inserted correctly without any error.

Hope it helps another members that experincing same error.

Thanks.

2 Likes

This topic was automatically closed after 4 days. New replies are no longer allowed.