View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
06443Bug reportsAssessmentspublic2012-08-16 10:23
Reporterfsando Assigned Toc_schmitz  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version2.00RC8 
Target Version2.00RC9Fixed in Version2.00RC9 
Summary06443: Adding new language to existing labelset results in "The active record cannot be inserted to database because it is not new. "
Description

Trying to add a new language to an existing labelset will result in an internal error.

Steps To Reproduce

1) Create a new labelset
2) Save it
3) Select the labelset and choose "edit"
4) Add a new langauge
5) Press the update button.

Additional Information

The error happens in
application/helpers/admin/label_helper.php (53-55):

if (isset($sqlvalues))
foreach ($sqlvalues as $sqlvalue)
Label::model()->insert($sqlvalue);

According to this link: http://www.yiiframework.com/forum/index.php/topic/8900-how-to-insert-data-record-using-insert-method/

insert() is a lowlevel function and one should rather use save() in stead of insert().

I have substituted this code for the three lines above.
It creates a new Label object for each new label and sets each sqlvalue property individually, then saves to database.

if (isset($sqlvalues)) {
foreach ($sqlvalues as $sqlvalue) {
$label = new Label();
foreach($sqlvalue as $k=>$v) {
$label->setAttribute($k,$v);
}
$label->save();
}
}

I have not tested extensively but it appears to work: no errors languages are added as expected, labels for one language do not disappear when other languages are updated.

TagsNo tags attached.
Bug heat4
Complete LimeSurvey version number (& build)120721
I will donate to the project if issue is resolvedNo
Browserfirefox 14.0.1 Ubuntu
Database type & versionmysql Ver 14.14 Distrib 5.5.24, for debian-linux-gnu (x86_64) using readline 6.2
Server OS (if known)Ubuntu 12.04 Linux 3.2.0-27-generic x86_64 x86_64
Webserver software & version (if known)Server version: Apache/2.2.22 (Ubuntu) Server built: Feb 13 2012 01:51:50
PHP VersionPHP 5.3.10-1ubuntu3.2 with Suhosin-Patch (cli) (built: Jun 13 2012 17:19:58)

Users monitoring this issue

There are no users monitoring this issue.

Activities

c_schmitz

c_schmitz

2012-08-07 11:06

administrator   ~20238

Looks great. Would you be able create a pull request on Github?

fsando

fsando

2012-08-07 16:30

reporter   ~20250

I'm pulling the code with git but not sure exactly what a pull request is. I'll look into it to night.

c_schmitz

c_schmitz

2012-08-07 20:48

administrator   ~20257

Please have a look at https://help.github.com/articles/using-pull-requests/

fsando

fsando

2012-08-08 16:08

reporter   ~20283

I made a pull request last night and it seemed to be effectuated, though this issue is still marked as open. Did I do something wrong?

c_schmitz

c_schmitz

2012-08-08 16:11

administrator   ~20284

Everything is fine - just forgot to close it ;)
Thank you for the pull request!

c_schmitz

c_schmitz

2012-08-16 10:23

administrator   ~20465

Version 2.00 RC 9 released.

Issue History

Date Modified Username Field Change
2012-08-07 03:01 fsando New Issue
2012-08-07 11:05 c_schmitz Assigned To => c_schmitz
2012-08-07 11:05 c_schmitz Status new => assigned
2012-08-07 11:06 c_schmitz Note Added: 20238
2012-08-07 16:30 fsando Note Added: 20250
2012-08-07 20:48 c_schmitz Note Added: 20257
2012-08-07 20:49 c_schmitz Status assigned => feedback
2012-08-08 16:08 fsando Note Added: 20283
2012-08-08 16:08 fsando Status feedback => assigned
2012-08-08 16:11 c_schmitz Note Added: 20284
2012-08-08 16:11 c_schmitz Status assigned => resolved
2012-08-08 16:11 c_schmitz Fixed in Version => 2.00+
2012-08-08 16:11 c_schmitz Resolution open => fixed
2012-08-12 15:32 c_schmitz Fixed in Version 2.00+ => 2.00RC9
2012-08-15 00:22 c_schmitz Target Version => 2.00RC9
2012-08-16 10:23 c_schmitz Note Added: 20465
2012-08-16 10:23 c_schmitz Status resolved => closed