View Issue Details

This bug affects 1 person(s).
 10
IDProjectCategoryView StatusLast Update
13744Bug reports_ Unknownpublic2018-08-07 17:01
Reportercaseylucas Assigned ToDenisChenu  
PrioritynoneSeverityminor 
Status closedResolutionfixed 
Product Version3.8.x 
Fixed in Version3.13.x 
Summary13744: unable to run db migration via command line (and fix)
Description

I am attempting to run db migration before starting up LS under FPM and am currently on db version 348. Note that LS version 3.9.0 needs to migrate to db version 349. I run (in application/commands directory)

php console.php updatedb

and get the following output:

Update pgsql:host=postgres;port=5432;user=XXXXX;password=XXXXX;dbname=dev; with prefix : from 348 to 349
Error: Call to undefined function setGlobalSetting() in /app/application/helpers/update/updatedb_helper.php:2268
Stack trace:
#0 /app/application/commands/UpdateDbCommand.php(42): db_upgrade_all(348)
#1 /app/framework/console/CConsoleCommandRunner.php(71): UpdateDBCommand->run(Array)
#2 /app/framework/console/CConsoleApplication.php(92): CConsoleCommandRunner->run(Array)
#3 /app/framework/base/CApplication.php(185): CConsoleApplication->processRequest()
#4 /app/application/commands/console.php(64): CApplication->run()
#5 {main}limesurvey_fpm_1 exited with code 1

Steps To Reproduce

Run the updatedb command but you must actually need a db migration. DB version 349 performs these updates (FYI - in case you need to back them out while testing):

ALTER TABLE "users" DROP COLUMN "one_time_pw"
ALTER TABLE "users" ADD COLUMN "one_time_pw" text
UPDATE "settings_global" SET "stg_value"='349' WHERE stg_name='DBVersion'
UPDATE "lime"."settings_global" SET "stg_name"='DBVersion', "stg_value"='349' WHERE "lime"."settings_global"."stg_name"='DBVersion'
INSERT INTO "lime"."notifications" ("status", "importance", "display_class", "entity", "entity_id", "title", "message", "created", "first_read") VALUES ('new', 1, 'default', 'user', 1, 'Database update', 'The database has been updated from version 348 to version 349.', NOW(), NULL)
INSERT INTO "lime"."settings_global" ("stg_name", "stg_value") VALUES ('defaulttheme', 'vanilla')

Additional Information

To fix the issue I added one line to UpdateDbCommand.php:

--- a/base/limesurvey/application/commands/UpdateDbCommand.php
+++ b/base/limesurvey/application/commands/UpdateDbCommand.php
@@ -39,6 +39,7 @@ class UpdateDBCommand extends CConsoleCommand
echo Yii::app()->db->tablePrefix." from {$currentDbVersion} to {$newDbVersion}\n";
Yii::import('application.helpers.common_helper', true);
Yii::import('application.helpers.update.updatedb_helper', true);

  • Yii::import('application.helpers.globalsettings_helper', true);
    $result = db_upgrade_all($currentDbVersion);
    if ($result) {
    echo "Database has been successfully upgraded to version $newDbVersion \n";
TagsNo tags attached.
Bug heat10
Complete LimeSurvey version number (& build)3.9.0+180604
I will donate to the project if issue is resolvedNo
Browsern/a
Database type & versionPostgres 348
Server OS (if known)linux
Webserver software & version (if known)FPM
PHP Version7.2

Users monitoring this issue

caseylucas

Activities

DenisChenu

DenisChenu

2018-06-08 00:23

developer   ~48024

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=27359

DenisChenu

DenisChenu

2018-06-08 00:24

developer   ~48025

No nee to load file : just setConfig again

caseylucas

caseylucas

2018-07-20 00:29

reporter   ~48538

I just tried to upgrade to latest (3.13.2+180709). This issue has not been resolved. See stack trace:

Error: Call to undefined function getGlobalSetting() in /var/www/html/application/models/TemplateManifest.php:605
Stack trace:
#0 /var/www/html/application/models/TemplateManifest.php(684): TemplateManifest->setPath()
#1 /var/www/html/application/models/TemplateConfiguration.php(654): TemplateManifest->setBasics()
#2 /var/www/html/application/helpers/update/updatedb_helper.php(2265): TemplateConfiguration->addOptionFromXMLToLiveTheme()
#3 /var/www/html/application/commands/UpdateDbCommand.php(42): db_upgrade_all(349)
#4 /var/www/html/framework/console/CConsoleCommandRunner.php(71): UpdateDBCommand->run(Array)
#5 /var/www/html/framework/console/CConsoleApplication.php(92): CConsoleCommandRunner->run(Array)
#6 /var/www/html/framework/base/CApplication.php(185): CConsoleApplication->processRequest()
#7 /var/www/html/application/commands/console.php(64): CApplication->run()
#8 {main}limesurvey_lime_1 exited with code 1

caseylucas

caseylucas

2018-07-20 04:08

reporter   ~48539

After digging a little deeper I realized that a similar problem ('getGlobalSetting' not being available) is manifesting itself in a different location (TemplateManifest->setPath()). This diff fixes the error:

--- a/base/application/models/TemplateManifest.php
+++ b/base/application/models/TemplateManifest.php
@@ -602,12 +602,12 @@ class TemplateManifest extends TemplateConfiguration
// If the template directory doesn't exist, we just set Default as the template to use
// TODO: create a method "setToDefault"
if (!is_dir($this->path)) {

  • $this->sTemplateName = getGlobalSetting('defaulttheme');
  • $this->sTemplateName = Yii::app()->getConfig('defaulttheme');
    $this->isStandard = true;
    $this->path = Yii::app()->getConfig("standardthemerootdir").DIRECTORY_SEPARATOR.$this->sTemplateName.DIRECTORY_SEPARATOR;
    if (!$this->iSurveyId) {
    // Why?
  • setGlobalSetting('defaulttheme', 'fruity');
  • Yii::app()->setConfig('defaulttheme', 'fruity');
    }
    }

Coincidentally, the code path in 'TemplateManifest->setPath' which calls get/setGlobalSetting was being executed because I was executing the updatedb outside of the application "rootdir". This caused the error to show up:

cd /var/www/html/application/commands
php console.php updatedb

However the error does not show up if I run (note the different path):

cd /var/www/html
php application/commands/console.php updatedb

DenisChenu

DenisChenu

2018-07-20 11:27

developer   ~48541

https://github.com/LimeSurvey/LimeSurvey/pull/1099

user70560

2018-07-28 14:02

  ~48608

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=27708

markusfluer

markusfluer

2018-08-07 17:01

administrator   ~48704

Release 3.14.2+180807

Related Changesets

LimeSurvey: master 83e3fb71

2018-06-08 00:23:41

DenisChenu

Details Diff
Fixed issue 13744: unable to run db migration via command line
Dev: please don't load uneeded file ;)
Affected Issues
13744
mod - application/helpers/globalsettings_helper.php Diff File
mod - application/helpers/update/updatedb_helper.php Diff File

LimeSurvey: master 9eac4140

2018-07-28 14:02:42

user70560


Committer: GitHub Details Diff
Fixed issue 13744: unable to run db migration via command line

Dev: remove unused SettingGlobal->model()->updateSetting function
Dev: add SettingGlobal::setSetting function
Dev: add demoMode rules in SettingGlobal model
Affected Issues
13744
mod - application/helpers/globalsettings_helper.php Diff File
mod - application/models/SettingGlobal.php Diff File
mod - application/models/TemplateManifest.php Diff File

Issue History

Date Modified Username Field Change
2018-06-07 01:34 caseylucas New Issue
2018-06-08 00:23 DenisChenu Changeset attached => LimeSurvey master 83e3fb71
2018-06-08 00:23 DenisChenu Note Added: 48024
2018-06-08 00:23 DenisChenu Assigned To => DenisChenu
2018-06-08 00:23 DenisChenu Resolution open => fixed
2018-06-08 00:24 DenisChenu Status new => resolved
2018-06-08 00:24 DenisChenu Fixed in Version => 3.8.x
2018-06-08 00:24 DenisChenu Note Added: 48025
2018-06-11 16:32 markusfluer Status resolved => closed
2018-06-11 16:32 markusfluer Fixed in Version 3.8.x => 3.10.x
2018-07-20 00:29 caseylucas Status closed => feedback
2018-07-20 00:29 caseylucas Resolution fixed => reopened
2018-07-20 00:29 caseylucas Note Added: 48538
2018-07-20 00:29 caseylucas Issue Monitored: caseylucas
2018-07-20 04:08 caseylucas Note Added: 48539
2018-07-20 04:08 caseylucas Status feedback => assigned
2018-07-20 11:27 DenisChenu Assigned To DenisChenu => markusfluer
2018-07-20 11:27 DenisChenu Note Added: 48541
2018-07-28 14:02 user70560 Changeset attached => LimeSurvey master 9eac4140
2018-07-28 14:02 user70560 Note Added: 48608
2018-07-29 17:19 DenisChenu Assigned To markusfluer => DenisChenu
2018-07-29 17:19 DenisChenu Status assigned => resolved
2018-07-29 17:19 DenisChenu Resolution reopened => fixed
2018-07-29 17:19 DenisChenu Fixed in Version 3.10.x => 3.13.x
2018-08-07 17:01 markusfluer Status resolved => closed
2018-08-07 17:01 markusfluer Note Added: 48704
2021-08-02 20:23 guest Bug heat 8 => 10