View Issue Details

IDProjectCategoryView StatusLast Update
15500Bug reports[All Projects] Pluginspublic2019-11-08 07:40
Reporteradamzammit Assigned To 
Status newResolutionopen 
Product Version3.19.3 
Target VersionFixed in Version 
Summary15500: getSurveyInfo() fails with fatal error for a plugin from console when tokens table with attributes set

When using the function getSurveyInfo() inside a plugin that is executed from the console AND the survey I am getting the info for has a tokens table AND has attributes set in the tokens table, I received the error:

PHP Fatal error: Class 'Token_XXXXXX' not found in /var/www/html/framework/db/ar/CActiveRecord.php on line 403

If the same function was called in the plugin NOT from the console, there was no error. Also if there was no tokens table set or a tokens table set with no attributes - there was no error.

I was able to track this down to the console init not importing and registering the ClassFactory.

Here is my solution:

In application/commands/console.php add the 3 lines indicated with "//add"

if (isset($config)) {
    $app = Yii::createApplication('ConsoleApplication', $config);
    define('APPPATH', Yii::app()->getBasePath().DIRECTORY_SEPARATOR);
    $env = (string) @getenv('YII_CONSOLE_COMMANDS');
    if (!empty($env)) {

    Yii::import('application.helpers.ClassFactory');     //add
    ClassFactory::registerClass('Token_', 'Token');   //add
   ClassFactory::registerClass('Response_', 'Response'); //add

Not sure if anyone else has encountered this or is happy to test?

TagsNo tags attached.
Complete LimeSurvey version number (& build)3.19.3
I will donate to the project if issue is resolvedNo
Database & DB-VersionMariaDb
Server OS (if known)
Webserver software & version (if known)
PHP Version7.2




2019-11-01 05:02

developer   ~54299

Hi @DenisChenu - I noticed this when working with the backupSurveyLocally plugin that I have forked from your repository on GitLab.

Do you notice this bug when using your plugin?




2019-11-01 11:21

developer   ~54315

No, because I didn't load Survey model :)

When i need Survey::model :



2019-11-04 06:15

developer   ~54378

Does the bug appear when getSurveyInfo() is called here:




2019-11-04 09:42

developer   ~54380

? right … i must look … but i use it on a 2.73 version … :/



2019-11-05 07:15

developer   ~54395

@adamzammit : checked : same issue …
Surely sendMailCron loaded before this plugin …



2019-11-08 04:53

developer   ~54477

Thanks @DenisChenu.

Do you think we should add the ClassFactory code to console.php or leave it up to the plugin to load?




2019-11-08 07:40

developer   ~54478

My opinion : must be loaded by core if needed … (When load Token or Response model ?) is the best.

Load by plugins is a workaround … then : load directly when using console (same for all other bug/issue when using console)

Issue History

Date Modified Username Field Change
2019-10-31 05:00 adamzammit New Issue
2019-10-31 05:01 adamzammit Description Updated View Revisions
2019-10-31 05:01 adamzammit Description Updated View Revisions
2019-11-01 05:02 adamzammit Note Added: 54299
2019-11-01 11:21 DenisChenu Note Added: 54315
2019-11-04 06:15 adamzammit Note Added: 54378
2019-11-04 09:42 DenisChenu Note Added: 54380
2019-11-05 07:15 DenisChenu Note Added: 54395
2019-11-08 04:53 adamzammit Note Added: 54477
2019-11-08 07:40 DenisChenu Note Added: 54478