View Issue Details

This bug affects 1 person(s).
 8
IDProjectCategoryView StatusLast Update
11248Bug reportsPluginspublic2016-05-25 09:03
ReporterResearchOnBlogs Assigned ToDenisChenu  
PrioritynoneSeveritycrash 
Status closedResolutionfixed 
Product Version2.50.x 
Target Version2.50.xFixed in Version2.50.x 
Summary11248: Saving plugin settings in survey causes an error - > demo plugin
Description

This part is not working without error anymore:

public function newSurveySettings()
{
    $event = $this->event;
            foreach ($event->get('settings') as $name => $value)
    {
        $this->set($name, $value, 'Survey', $event->get('survey'));
    }
}

You get an php warning :
Invalid argument supplied for foreach()

My debug mode is on. How to solve this?

The $event->get gets an array, but we get a warning in this foreach. I have no clue..

Steps To Reproduce

Put this plugin : https://github.com/LimeSurvey/LimeSurvey/tree/master/plugins/Demo/Example

in plugins directory
activate
got to survey settings

TagsNo tags attached.
Attached Files
Bug heat8
Complete LimeSurvey version number (& build)latest master
I will donate to the project if issue is resolvedNo
Browser
Database type & versionxx
Server OS (if known)xx
Webserver software & version (if known)xx
PHP Versionxx

Users monitoring this issue

There are no users monitoring this issue.

Activities

DenisChenu

DenisChenu

2016-05-24 14:28

developer   ~38772

What is the demo plugin please ?
I have it friday on a plugin, but not today :! can you control again ?

ResearchOnBlogs

ResearchOnBlogs

2016-05-24 14:42

developer   ~38773

This is the plugin class

class Example extends PluginBase {...

DenisChenu

DenisChenu

2016-05-24 15:59

developer   ~38781

Last edited: 2016-05-24 16:00

Yes : can reproduce with exampleSettings too ....

DenisChenu

DenisChenu

2016-05-24 16:08

developer   ~38783

Second time called here : https://github.com/LimeSurvey/LimeSurvey/blob/master/application/controllers/admin/database.php#L1162

But buggy

DenisChenu

DenisChenu

2016-05-24 16:18

developer   ~38790

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

DenisChenu

DenisChenu

2016-05-24 16:22

developer   ~38791

@aesteban : i surely broke something in AuditLog
but the fix done break all other plugin.

And more : same function call twice and adding uneeded partam in event (see comments)
https://github.com/LimeSurvey/LimeSurvey/commit/e8f6f767adb65a57380d6f38dca3a58b9b0c9484#commitcomment-17595855

dgimeno

dgimeno

2016-05-24 17:32

reporter   ~38803

@DenisChenu I think I really need OSurvey object because inside the suscribed method newSurveySettings I compare before and after and I then can log modified settings with a:
array_diff_assoc($newAttributes, $oldAttributes)

It's true that is not necesary the Id, but I think adds clarity.
Next commit i'll remove it.

DenisChenu

DenisChenu

2016-05-24 17:43

developer   ~38805

Actually :

In the plugin :
$oSurvey=Survey::model()->findByPk($this->event()->get('survey');
$aUpdadtedAttribute=array();
foreach($oSurvey->attributes as $sAttribute)
{
$newAttribute=App()->request->getPost($sAttribute)
if(!is_null($newAttribute) && $newAttribute!=$sAttribute)
$aUpdadtedAttribute=array("old"=>$sAttribute,"new"=>$newAttribute);
}

or something like that.

DenisChenu

DenisChenu

2016-05-24 17:45

developer   ~38806

PS: see my comment https://github.com/LimeSurvey/LimeSurvey/commit/7c3efa819cf00ce466f6c66853c9f1200c1635cc#diff-4c8b6e0396ccd2f7fad4f57489b63b06R1076

actually leave it before saving core : we are sure core settings is saved in LS way.

But you can move it if you need.

DenisChenu

DenisChenu

2016-05-24 19:05

developer   ~38812

Bug is resolved :)

c_schmitz

c_schmitz

2016-05-25 09:03

administrator   ~38822

Version 2.50+ Build 160525 & Version 2.06LTS Build 160524 released

Related Changesets

LimeSurvey: master 7c3efa81

2016-05-24 14:18:07

DenisChenu

Details Diff
Fixed issue 11248: Saving plugin survey settings send PHP notice
Dev: remove the second call to same function
Dev: https://github.com/LimeSurvey/LimeSurvey/commit/e8f6f767adb65a57380d6f38dca3a58b9b0c9484 child
Affected Issues
11248
mod - application/controllers/admin/database.php Diff File

Issue History

Date Modified Username Field Change
2016-05-24 10:37 ResearchOnBlogs New Issue
2016-05-24 10:37 ResearchOnBlogs File Added: Bildschirmfoto 2016-05-24 um 10.32.36.png
2016-05-24 14:28 DenisChenu Note Added: 38772
2016-05-24 14:42 ResearchOnBlogs Note Added: 38773
2016-05-24 15:59 DenisChenu Note Added: 38781
2016-05-24 15:59 DenisChenu Description Updated
2016-05-24 15:59 DenisChenu Steps to Reproduce Updated
2016-05-24 16:00 DenisChenu Note Edited: 38781
2016-05-24 16:08 DenisChenu Assigned To => DenisChenu
2016-05-24 16:08 DenisChenu Status new => assigned
2016-05-24 16:08 DenisChenu Note Added: 38783
2016-05-24 16:10 DenisChenu Assigned To DenisChenu => aesteban
2016-05-24 16:18 DenisChenu Changeset attached => LimeSurvey master 7c3efa81
2016-05-24 16:18 DenisChenu Note Added: 38790
2016-05-24 16:18 DenisChenu Assigned To aesteban => DenisChenu
2016-05-24 16:18 DenisChenu Resolution open => fixed
2016-05-24 16:20 DenisChenu Status assigned => resolved
2016-05-24 16:20 DenisChenu Fixed in Version => 2.5
2016-05-24 16:22 DenisChenu Assigned To DenisChenu => aesteban
2016-05-24 16:22 DenisChenu Note Added: 38791
2016-05-24 16:22 DenisChenu Status resolved => feedback
2016-05-24 16:22 DenisChenu Resolution fixed => reopened
2016-05-24 17:32 dgimeno Note Added: 38803
2016-05-24 17:43 DenisChenu Note Added: 38805
2016-05-24 17:45 DenisChenu Note Added: 38806
2016-05-24 19:05 DenisChenu Note Added: 38812
2016-05-24 19:05 DenisChenu Status feedback => resolved
2016-05-24 19:05 DenisChenu Resolution reopened => fixed
2016-05-24 19:05 DenisChenu Assigned To aesteban => DenisChenu
2016-05-25 09:03 c_schmitz Note Added: 38822
2016-05-25 09:03 c_schmitz Status resolved => closed