Hi,
I develop a plugin for LimeSurvey – latest v3 – and do read some settings variables via the plugins method $this->get('somekey') ... The plugin is called as a console application either directly or as a cron job.
This worked flawlessly until after some time I added a new setting in the settings array. Since then I get a strange error:
Code:
PHP Error[2]: session_name(): Cannot change session name when headers already sent
in file /var/www/html/limesurvey/framework/web/CHttpSession.php at line 206
#0 /var/www/html/limesurvey/framework/web/CHttpSession.php(206): session_name()
#1 /var/www/html/limesurvey/framework/base/CComponent.php(152): ConsoleHttpSession->setSessionName()
#2 /var/www/html/limesurvey/framework/YiiBase.php(227): ConsoleHttpSession->__set()
#3 /var/www/html/limesurvey/framework/base/CModule.php(393): createComponent()
#4 /var/www/html/limesurvey/framework/base/CModule.php(118): ConsoleApplication->getComponent()
#5 /var/www/html/limesurvey/application/helpers/common_helper.php(1420): ConsoleApplication->__isset()
#6 /var/www/html/limesurvey/application/libraries/PluginManager/LimesurveyApi.php(202): createFieldMap()
#7 /var/www/html/limesurvey/application/libraries/PluginManager/LimesurveyApi.php(235): LimeSurvey\PluginManager\LimesurveyApi->getResponse()
#8 /var/www/html/limesurvey/plugins/ICPlugin/ICPlugin.php(906): LimeSurvey\PluginManager\LimesurveyApi->getResponsesByTokens()
#9 /var/www/html/limesurvey/plugins/ICPlugin/ICPlugin.php(696): ICPlugin->getResponsesFromParticipants()
#10 /var/www/html/limesurvey/plugins/ICPlugin/ICPlugin.php(555): ICPlugin->evaluateFPbackgroundProcess()
#11 /var/www/html/limesurvey/plugins/ICPlugin/ICPlugin.php(538): ICPlugin->evaluateICbackgroundProcess()
#12 unknown(0): ICPlugin->backgroundProcessDirect()
#13 /var/www/html/limesurvey/application/libraries/PluginManager/PluginManager.php(185): call_user_func()
#14 /var/www/html/limesurvey/application/commands/PluginCommand.php(45): LimeSurvey\PluginManager\PluginManager->dispatchEvent()
#15 unknown(0): PluginCommand->actionIndex()
#16 /var/www/html/limesurvey/framework/console/CConsoleCommand.php(172): ReflectionMethod->invokeArgs()
#17 /var/www/html/limesurvey/framework/console/CConsoleCommandRunner.php(71): PluginCommand->run()
#18 /var/www/html/limesurvey/framework/console/CConsoleApplication.php(92): CConsoleCommandRunner->run()
#19 /var/www/html/limesurvey/framework/base/CApplication.php(185): ConsoleApplication->processRequest()
#20 /var/www/html/limesurvey/application/commands/console.php(64): ConsoleApplication->run()
The get part in my plugin looks like this:
Code:
$sdoitagainfp = $this->get('doitagainfp');
if (strlen($sdoitagainfp) > 0 ) {
$doitagainfp = explode(",", $sdoitagainfp);
if ( $doitagainfp ) {
$this->pluginsettings['doitagainfp'] = $doitagainfp;
if ($this->pluginsettings['debugmode']) $this->log("reset FP IDs: " . print_r($doitagainfp,true) );
}
}
When I comment out the GET of this variable, the error disappears.
What I don't understand, is, that the error appears somewhere in the API calls.
Note, that I added the API function getResponsesByTokens as a simple wrapper to the getResponse function:
Code:
public function getResponsesByTokens($surveyId, $aTokens, $bMapQuestionCodes = true)
{
$result = array();
foreach ($aTokens as $token) {
$oResponse = SurveyDynamic::model($surveyId)->findByAttributes(array('token'=>$token));
if ( $oResponse ){
$result[] = $this->getResponse($surveyId, $oResponse->id, $bMapQuestionCodes);
}
}
return $result;
}
For this wrapper function I would like to do a pull request later, however at the moment I'm struggling with the PHP error.
If somebody could comment on this error, I would be happy. I can, of course, also deliver more information.
Thanks,
Maarten