Upgrade OJS 2.4.8 >> OJS 3.0.2 prevented by DB error

Hello,
this morning we tried to make the big leap forwards from OJS 2.4.6 to OJS 3.0.2
We worked with the stable version of 3.0.2 downloaded form the PKP website. We did set the config.inc.php at installed = Off.
We used the browser procedure to upgrade the database. This resulted in a white page and we were not able to move forward. The fatal error that appeared in the log is:

PHP Fatal error: require_once(): Failed opening required '/data/html/ojs-3.0.2/plugins/generic/usageStats/GeoLocationTool.inc.php'

The complete error overview is included below.

We noticed that a file with the name GeoLocationTool.inc.php sits in a different folder in the library. We did copy that file to the place where the installation procedure is expecting it but that move resulted in a DB Error: Column ‘load_id’ cannot be null.

Suggestions how to solve this are welcome

   [   Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP Stack trace:, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP   1. {main}() /data/html/ojs-3.0.2/index.php:0, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP   2. PKPApplication->execute() /data/html/ojs-3.0.2/index.php:68, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP   3. Dispatcher->dispatch() /data/html/ojs-3.0.2/lib/pkp/classes/core/PKPApplication.inc.php:227, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP   4. PKPPageRouter->route() /data/html/ojs-3.0.2/lib/pkp/classes/core/Dispatcher.inc.php:134, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP   5. PKPRouter->_authorizeInitializeAndCallRequest() /data/html/ojs-3.0.2/lib/pkp/classes/core/PKPPageRouter.inc.php:239, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP   6. call_user_func() /data/html/ojs-3.0.2/lib/pkp/classes/core/PKPRouter.inc.php:372, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP   7. InstallHandler->installUpgrade() /data/html/ojs-3.0.2/lib/pkp/classes/core/PKPRouter.inc.php:372, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP   8. UpgradeForm->execute() /data/html/ojs-3.0.2/lib/pkp/pages/install/InstallHandler.inc.php:110, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP   9. Installer->execute() /data/html/ojs-3.0.2/lib/pkp/classes/install/form/UpgradeForm.inc.php:40, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP  10. Installer->executeInstaller() /data/html/ojs-3.0.2/lib/pkp/classes/install/Installer.inc.php:186, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP  11. Installer->executeAction() /data/html/ojs-3.0.2/lib/pkp/classes/install/Installer.inc.php:265, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP  12. call_user_func() /data/html/ojs-3.0.2/lib/pkp/classes/install/Installer.inc.php:415, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP  13. Upgrade->migrateTimedViewsUsageStatistics() /data/html/ojs-3.0.2/lib/pkp/classes/install/Installer.inc.php:415, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP  14. import() /data/html/ojs-3.0.2/classes/install/Upgrade.inc.php:526, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP Fatal error:  require_once(): Failed opening required '/data/html/ojs-3.0.2/plugins/generic/usageStats/GeoLocationTool.inc.php' (include_path='.:/data/html/ojs-3.0.2/classes:/data/html/ojs-3.0.2/pages:/data/html/ojs-3.0.2/lib/pkp:/data/html/ojs-3.0.2/lib/pkp/classes:/data/html/ojs-3.0.2/lib/pkp/pages:/data/html/ojs-3.0.2/lib/pkp/lib/adodb:/data/html/ojs-3.0.2/lib/pkp/lib/phputf8:/data/html/ojs-3.0.2/lib/pkp/lib/pqp/classes:/data/html/ojs-3.0.2/lib/pkp/lib/smarty:.:/usr/share/pear:/usr/share/php') in /data/html/ojs-3.0.2/lib/pkp/includes/functions.inc.php on line 25, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP Stack trace:, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP   1. {main}() /data/html/ojs-3.0.2/index.php:0, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP   2. PKPApplication->execute() /data/html/ojs-3.0.2/index.php:68, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP   3. Dispatcher->dispatch() /data/html/ojs-3.0.2/lib/pkp/classes/core/PKPApplication.inc.php:227, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP   4. PKPPageRouter->route() /data/html/ojs-3.0.2/lib/pkp/classes/core/Dispatcher.inc.php:134, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP   5. PKPRouter->_authorizeInitializeAndCallRequest() /data/html/ojs-3.0.2/lib/pkp/classes/core/PKPPageRouter.inc.php:239, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP   6. call_user_func() /data/html/ojs-3.0.2/lib/pkp/classes/core/PKPRouter.inc.php:372, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP   7. InstallHandler->installUpgrade() /data/html/ojs-3.0.2/lib/pkp/classes/core/PKPRouter.inc.php:372, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP   8. UpgradeForm->execute() /data/html/ojs-3.0.2/lib/pkp/pages/install/InstallHandler.inc.php:110, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP   9. Installer->execute() /data/html/ojs-3.0.2/lib/pkp/classes/install/form/UpgradeForm.inc.php:40, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP  10. Installer->executeInstaller() /data/html/ojs-3.0.2/lib/pkp/classes/install/Installer.inc.php:186, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP  11. Installer->executeAction() /data/html/ojs-3.0.2/lib/pkp/classes/install/Installer.inc.php:265, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP  12. call_user_func() /data/html/ojs-3.0.2/lib/pkp/classes/install/Installer.inc.php:415, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP  13. Upgrade->migrateTimedViewsUsageStatistics() /data/html/ojs-3.0.2/lib/pkp/classes/install/Installer.inc.php:415, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade
    [Fri Jun 09 10:59:24 2017] [error] [client XXX.XXX.XX.X] PHP  14. import() /data/html/ojs-3.0.2/classes/install/Upgrade.inc.php:526, referer: http://journals.library.tudelft.nl/index.php/index/install/upgrade

Hi @Franklinx,

Did you unpack the OJS 3.0.2 code over top of the OJS 2.4.6 codebase? If so, then your installation will have a mixture of code from the two versions. Check the “Full Package” installation instructions carefully.

Regards,
Alec Smecher
Public Knowledge Project Team

Alec, we didn’t unpack the OJS 3.0.2 code over top of the OJS 2.4.6 codebase. What else could be the root fo the problem at this point?

Hi @Franklinx,

I think the patch on issue #2580 will resolve the import issue. Could you remove your extra copy of the class, apply the patch, and try the upgrade again?

When you try the upgrade again, make sure you restore your database and files directory from backup first. Otherwise the upgrade will attempt to run on an already partially upgraded copy and likely won’t work.

Regards,
Alec Smecher
Public Knowledge Project Team

Alec, thanks for the patch but it didn’t work out. After applying the patch we ran into a

“DB Error: Column 'load_id' cannot be null”

(by the way: The change that you have suggested refers to line 526 in the script and not to line 546.)

After contemplating what to do, we decided to put the latest version of our production database in our test environment just to rule out that the database is not what is causing the problem here.

Using this version of the database we decided to try an incremental approach. The upgrade from version 2.4.6 to version 2.4.8-2 went smooth using the command line procedure. However, the upgrade from version 2.4.8-2 to version 3.0.2 is failing once more. Once more we got the error:

DB Error: Column 'load_id' cannot be null.

See the copy of the log below in this post.

The upgrades were performed with a solid database. We worked with a cleanly installed version 2.4.8-2 without modifications and a cleanly installed version 3.0.2. We followed the instructions in the UPGRADE file carefully. We need some help at this point.

Looking at the log below it seems that the function insert is called with 8 arguments while there are actually 9 defined.

Please compare:

/data/html/ojs-3.0.2/lib/pkp/plugins/generic/usageStats/UsageStatsTemporaryRecordDAO.inc.php
line 48:
function insert($assocType, $assocId, $day, $time, $countryCode, $region, $cityName, $fileType, $loadId)

with

/data/html/ojs-3.0.2/classes/install/Upgrade.inc.php
line 541:
$tempStatsDao->insert($assocType, $assocId, $day, $countryId, $region, $cityName, null, $loadId);

Here is the log:

> $ php tools/upgrade.php upgrade
> [pre-install]
> [load: upgrade.xml]
> [version: 3.0.2.0]
> [code: Installer Installer::syncSeriesAssocType]
> [data: dbscripts/xml/upgrade/2.4.0_preupdate_usageStatistics.xml (skipped)]
> [data: dbscripts/xml/upgrade/2.4.0_preupdate_usageStatistics2.xml]
> [data: dbscripts/xml/upgrade/3.0.0_preupdate.xml]
> [data: dbscripts/xml/upgrade/3.0.0_adaptTimedViews.xml]
> [data: dbscripts/xml/upgrade/3.0.0_adaptReferrals.xml]
> [data: dbscripts/xml/upgrade/3.0.0_adaptBooksForReview.xml]
> [data: dbscripts/xml/upgrade/remove_timed_views_bots.xml]
> [code: Installer Installer::migrateCounterPluginUsageStatistics]
> [code: Installer Installer::migrateTimedViewsUsageStatistics]
> PHP Warning:  Missing argument 9 for UsageStatsTemporaryRecordDAO::insert(), called in /data/html/ojs-3.0.2/classes/install/Upgrade.inc.php on line 541 and defined in /data/html/ojs-3.0.2/lib/pkp/plugins/generic/usageStats/UsageStatsTemporaryRecordDAO.inc.php on line 48
> PHP Stack trace:
> PHP   1. {main}() /data/html/ojs-3.0.2/tools/upgrade.php:0
> PHP   2. UpgradeTool->execute() /data/html/ojs-3.0.2/tools/upgrade.php:34
> PHP   3. UpgradeTool->upgrade() /data/html/ojs-3.0.2/lib/pkp/classes/cliTool/UpgradeTool.inc.php:64
> PHP   4. Installer->execute() /data/html/ojs-3.0.2/lib/pkp/classes/cliTool/UpgradeTool.inc.php:88
> PHP   5. Installer->executeInstaller() /data/html/ojs-3.0.2/lib/pkp/classes/install/Installer.inc.php:186
> PHP   6. Installer->executeAction() /data/html/ojs-3.0.2/lib/pkp/classes/install/Installer.inc.php:265
> PHP   7. call_user_func() /data/html/ojs-3.0.2/lib/pkp/classes/install/Installer.inc.php:415
> PHP   8. Upgrade->migrateTimedViewsUsageStatistics() /data/html/ojs-3.0.2/lib/pkp/classes/install/Installer.inc.php:415
> PHP   9. UsageStatsTemporaryRecordDAO->insert() /data/html/ojs-3.0.2/classes/install/Upgrade.inc.php:541
> PHP Notice:  Undefined variable: loadId in /data/html/ojs-3.0.2/lib/pkp/plugins/generic/usageStats/UsageStatsTemporaryRecordDAO.inc.php on line 64
> PHP Stack trace:
> PHP   1. {main}() /data/html/ojs-3.0.2/tools/upgrade.php:0
> PHP   2. UpgradeTool->execute() /data/html/ojs-3.0.2/tools/upgrade.php:34
> PHP   3. UpgradeTool->upgrade() /data/html/ojs-3.0.2/lib/pkp/classes/cliTool/UpgradeTool.inc.php:64
> PHP   4. Installer->execute() /data/html/ojs-3.0.2/lib/pkp/classes/cliTool/UpgradeTool.inc.php:88
> PHP   5. Installer->executeInstaller() /data/html/ojs-3.0.2/lib/pkp/classes/install/Installer.inc.php:186
> PHP   6. Installer->executeAction() /data/html/ojs-3.0.2/lib/pkp/classes/install/Installer.inc.php:265
> PHP   7. call_user_func() /data/html/ojs-3.0.2/lib/pkp/classes/install/Installer.inc.php:415
> PHP   8. Upgrade->migrateTimedViewsUsageStatistics() /data/html/ojs-3.0.2/lib/pkp/classes/install/Installer.inc.php:415
> PHP   9. UsageStatsTemporaryRecordDAO->insert() /data/html/ojs-3.0.2/classes/install/Upgrade.inc.php:541
> <h1>DB Error: Column 'load_id' cannot be null</h1>ojs2: DB Error: Column 'load_id' cannot be null

Hi @Franklinx

Hmmm… Yes this seems to be a bug in the upgrade script in 3.0.2. However, if you have upgraded to 2.4.8-2 correctly/successfully, this code should not be executed any more for the 3.0.2 upgrade. Thus, could you please double check your update to 2.4.8-2? After the upgrade there should be no DB table ‘timed_views_log’ any more. All their entries should be migrated to the DB table metrics.
The existence of that table is the condition for that code execution, s. https://github.com/pkp/ojs/blob/master/dbscripts/xml/upgrade.xml#L78.

It would be great if you could then also test the upgrade from 2.4.6 to 3.0.2 once again, with the following fix of that line 541 in classes/install/Upgrade.inc.php: Could you please add one more parameter (strtotime($row['date'])), so that it looks like this:
$tempStatsDao->insert($assocType, $assocId, $day, strtotime($row['date']), $countryId, $region, $cityName, null, $loadId);

Thanks a lot!
Bozana

Hi @bozana,

Just ran into this issue during an OJS 3.1 upgrade and wanted to confirm that your suggestion fixed the problem (in case this has not already been filed as a bug).

Cheers,
Michael

Thanks a lot @mfelczak! I’ve totally forgotten about this issue :frowning:
Will make a PR…

s. this GitHub Issue for the fix: fix migrateTimedViewsUsageStatistics · Issue #3220 · pkp/pkp-lib · GitHub