View Issue Details

This bug affects 2 person(s).
 22
IDProjectCategoryView StatusLast Update
19049Bug reportsImport/Exportpublic2024-02-06 17:38
Reporteradamzammit Assigned Totibor.pacalat  
PrioritynoneSeverityminor 
Status closedResolutionfixed 
Product Version6.2.x 
Summary19049: Cannot export LSS from survey where theme is set to one extended from 'bootswatch'
Description

Trying to export to LSS from a survey with a theme extended from bootswatch causes a 500 error.

Error occurs here: https://github.com/LimeSurvey/LimeSurvey/blob/f62e9142e45b665796eec774a9368517161121f4/application/helpers/export_helper.php#L3138

Caused by this: https://github.com/LimeSurvey/LimeSurvey/blob/f62e9142e45b665796eec774a9368517161121f4/application/models/TemplateConfiguration.php#L318

that returns an array with objects in it "@attribute"->"cssframework" . This breaks simplexml as it is expecting an array

Steps To Reproduce

Steps to reproduce

Create a theme by extending the bootswatch theme
Create a new survey that uses the bootswatch theme
Export to LSS

Expected result

Download LSS File

Actual result

500 error

TagsNo tags attached.
Attached Files
Bug heat22
Complete LimeSurvey version number (& build)6.2.4
I will donate to the project if issue is resolvedNo
Browser
Database type & versionMariadb 10.5
Server OS (if known)
Webserver software & version (if known)
PHP Version8.1

Relationships

related to 18895 resolvedtibor.pacalat No way to add textarea with core config.xml 

Users monitoring this issue

There are no users monitoring this issue.

Activities

gabrieljenik

gabrieljenik

2023-10-06 21:56

manager   ~77551

This is very complicated, but we have a fix.
Will post on Monday

gabrieljenik

gabrieljenik

2023-10-09 21:04

manager   ~77593

Last edited: 2023-10-09 21:17

Master: https://github.com/LimeSurvey/LimeSurvey/pull/3521

The patch is only for the source of the problem, which is when a theme is extended.
For already extended themes, we need a DB update.

The problem happened when loading the config.xml.
Bootswatch has an XML which could be thought as, somehow, non-well-formed XML (or at least a form of XML that is not expected or handled consistently by SimpleXMLElements).
I have seen this only in Bootswatch.

When there is a default value:

<options>
<cssframework type="dropdown" category="Simple options" title="Variations" parent="cssframework">
Default value
<dropdownoptions>
<option>Test</option>
</dropdownoptions>
</cssframework>
</options>

This is transformed to PHP (and then JSON), as

{options: {css-framework: 'Default Value'}}

When there is NO default value:

<options>
<cssframework type="dropdown" category="Simple options" title="Variations" parent="cssframework">
<dropdownoptions>
<option>Test</option>
</dropdownoptions>
</cssframework>
</options>

This is transformed to PHP (and then JSON), as

{options: {css-framework: {dropdownoptions: {option: 'test'}}}}}`

So, when there is no default value, the internal nodes (dropdownoptions) are intended to be included into the LSS.
writeXmlFromArray can deal with arrays, ints, strings, ... but is not prepared for stdClass.
That's when the XMLWriter fails.
https://github.com/LimeSurvey/LimeSurvey/blob/f62e9142e45b665796eec774a9368517161121f4/application/helpers/export_helper.php#L3110C28-L3110C38

Summing up:

  • The problem occurred when loading the config.xml.
  • To save the options in the database, they are converted to JSON, with the TemplateConfig::formatToJsonArray() method.
  • We created a new method, that, when detecting empty nodes, traverses different through the elements, not allowing multiple levels of indentation.

This should also happen on Fruity, as it doesn't have a default value.
In the new fruity, there is a default value, so there shoudn't be hits on that theme.

Would love to listen to your thoughts before approaching the update routine.

Thanks

adamzammit

adamzammit

2023-10-09 23:57

developer   ~77597

Thanks @gabrieljenik for debugging this.

If the "Default value" was stored in a tag or as an attribute, could the XML traversal be normalised?

DenisChenu

DenisChenu

2023-10-10 10:50

developer   ~77599

Maybe Adam can review code ?

gabrieljenik

gabrieljenik

2023-10-10 14:41

manager   ~77610

If the "Default value" was stored in a tag or as an attribute, could the XML traversal be normalised?

Actually, when storing as json on DB, LS code doesn't expect more nodes under an options node.
When there is "default value" text node, the nodes are somehow "lost in translation" and everything fits.
The problem is when there is no text node and hence the nodes under it are intended to be saved to the DB.

So I would store it as a an attribute.

DenisChenu

DenisChenu

2023-11-13 08:51

developer   ~78399

Bootswatch has an XML which could be thought as, somehow, non-well-formed XML (or at least a form of XML that is not expected or handled consistently by SimpleXMLElements).

This part must be fixed too : we must use only valid XML, no ?
(Must create a dev issue)

Mazi

Mazi

2023-11-23 14:19

updater   ~78678

I am facing a very similar issue. Exporting a survey using "fruity" theme works fine. If I then assign "extend_fruity" child theme, the export fails. -> Is this the same issue? Since at the issue description only Bootstrap is mentioned.

gabrieljenik

gabrieljenik

2023-11-23 14:27

manager   ~78680

Is this the same issue? Since at the issue description only Bootstrap is mentioned.

Could be. I found stuff in the config.xml that resembles the conditions for this bug

tibor.pacalat

tibor.pacalat

2023-11-23 16:33

administrator   ~78688

@gabrieljenik how can I reproduce this issue?
I followed instructions in the ticket, but I couldn't reproduce this on latest master.
Is this only happening with MariaDB?

gabrieljenik

gabrieljenik

2023-11-24 16:48

manager   ~78710

Seems @olle added a default value for the variation option on the Bootswatch config.xml on 19232 https://github.com/LimeSurvey/LimeSurvey/commit/eb27f86043718396dd71bcbde31b898683114615 .

That made the problem to be hidden.
To reproduce, please use the latest release (which still doean't have that update)

tibor.pacalat

tibor.pacalat

2023-11-27 14:01

administrator   ~78732

I can export surveys that use extended bootswatch and fruity themes.

guest

guest

2023-11-27 14:02

viewer   ~78733

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

LimeBot

LimeBot

2023-12-04 12:58

administrator   ~78862

Fixed in Release 6.3.8+231204

bquiller

bquiller

2024-02-06 09:56

reporter   ~79423

This bug seems to still affect version 6.4.5+240205

tibor.pacalat

tibor.pacalat

2024-02-06 17:38

administrator   ~79427

@bquiller I have just tested this using these steps:

  1. Create a theme by extending the bootswatch theme
  2. Create a new survey that uses the extended bootswatch theme
  3. Export to LSS

and I managed to successfully download the lss file using LS version 6.4.5+240205.

Can you give me more details about your environment (browser, database ... ) and steps on how I could reproduce what you are seeing?

Related Changesets

LimeSurvey: master 10ba9048

2023-11-27 14:02:22

Gabriel Jenik


Committer: GitHub Details Diff
Fixed issue 19049: Cannot export LSS from survey where theme is set to one extended from 'bootswatch' (03521) Affected Issues
19049
mod - application/models/TemplateConfig.php Diff File
mod - application/models/TemplateManifest.php Diff File
add - tests/unit/models/TemplateConfigTest.php Diff File

Issue History

Date Modified Username Field Change
2023-08-25 02:55 adamzammit New Issue
2023-08-25 02:55 adamzammit File Added: limesurvey-error-export-after-template-2023-08-25_09.45.20.m4v
2023-09-14 14:18 gabrieljenik Assigned To => gabrieljenik
2023-09-14 14:18 gabrieljenik Status new => assigned
2023-10-06 21:56 gabrieljenik Note Added: 77551
2023-10-06 21:56 gabrieljenik Bug heat 0 => 2
2023-10-09 21:04 gabrieljenik Note Added: 77593
2023-10-09 21:05 gabrieljenik Note Edited: 77593
2023-10-09 21:06 gabrieljenik Note Edited: 77593
2023-10-09 21:09 gabrieljenik Note Edited: 77593
2023-10-09 21:17 gabrieljenik Note Edited: 77593
2023-10-09 23:57 adamzammit Note Added: 77597
2023-10-09 23:57 adamzammit Bug heat 2 => 4
2023-10-10 10:50 DenisChenu Note Added: 77599
2023-10-10 10:50 DenisChenu Bug heat 4 => 6
2023-10-10 14:41 gabrieljenik Note Added: 77610
2023-11-02 12:19 DenisChenu Relationship added related to 18895
2023-11-13 08:51 DenisChenu Note Added: 78399
2023-11-22 12:58 gabrieljenik Assigned To gabrieljenik => DenisChenu
2023-11-22 12:58 gabrieljenik Status assigned => ready for code review
2023-11-22 16:04 DenisChenu Assigned To DenisChenu => tibor.pacalat
2023-11-22 16:04 DenisChenu Status ready for code review => ready for testing
2023-11-23 14:19 Mazi Note Added: 78678
2023-11-23 14:19 Mazi Bug heat 6 => 14
2023-11-23 14:27 gabrieljenik Note Added: 78680
2023-11-23 16:33 tibor.pacalat Note Added: 78688
2023-11-23 16:33 tibor.pacalat Bug heat 14 => 16
2023-11-24 16:48 gabrieljenik Note Added: 78710
2023-11-27 14:01 tibor.pacalat Note Added: 78732
2023-11-27 14:02 Changeset attached => LimeSurvey master 10ba9048
2023-11-27 14:02 guest Note Added: 78733
2023-11-27 14:02 guest Bug heat 16 => 18
2023-11-27 17:25 tibor.pacalat Status ready for testing => resolved
2023-11-27 17:25 tibor.pacalat Resolution open => fixed
2023-12-04 12:58 LimeBot Note Added: 78862
2023-12-04 12:58 LimeBot Status resolved => closed
2023-12-04 12:58 LimeBot Bug heat 18 => 20
2024-02-06 09:56 bquiller Note Added: 79423
2024-02-06 09:56 bquiller Bug heat 20 => 22
2024-02-06 17:38 tibor.pacalat Note Added: 79427