View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 20897 | Bug reports | Import/Export | public | 2026-11-25 16:23 | 2026-11-25 17:21 |
| Reporter | jannik3445 | Assigned To | p_teichmann | ||
| Priority | none | Severity | minor | ||
| Status | ready for code review | Resolution | open | ||
| Product Version | 7.12.x | ||||
| Summary | 20897: Survey, group and question export lose and duplicate question attributes on PostgreSQL (no ORDER BY in chunked query) | ||||
| Description | On PostgreSQL, the LSS export of a survey with more than 1,000 question attribute rows is wrong. Some attribute rows are in the export twice, and the same number of other rows are missing, so the total row count looks correct. The export imports without any error, but the imported survey has lost the missing attributes (for example cssclass, hidden, validation settings). Which rows are lost changes from one export to the next. In our installation, 6 large surveys (about 2,000 to 5,000 attribute rows each) lost between 500 and 1,200 attribute rows each in every LSS export. The LSG and LSQ exports use the same query and have the same problem. This is the same kind of bug as 20397. The fix for 20397 (commit 352fa9060f964a4bd78c92b6768e3c99f801fc12) added an ORDER BY to the answer and l10n queries, but not to the question attribute queries. Cause buildXMLFromQuery() reads the result in chunks of 1,000 rows with LIMIT/OFFSET: The question attribute queries use GROUP BY but no ORDER BY:
Without ORDER BY, PostgreSQL does not keep the same row order between the chunk queries. With GROUP BY it often uses a hash aggregate, so the order changes and the chunks overlap and leave gaps. MariaDB and MySQL up to 5.7 sort GROUP BY results, so the bug usually does not show there. MySQL 8 no longer guarantees this order either. The two SELECT DISTINCT conditions queries have no ORDER BY either: Suggested fix Add a fixed and unique order to these queries, as the 20397 fix did (https://github.com/LimeSurvey/LimeSurvey/blob/eb326311a4c1c386b24384b77226560db2a3c5fc/application/helpers/export_helper.php#L889-L905):
We run this patch on our LimeSurvey 7.12.1 installation. After it, all exports have every attribute row exactly once. I can open a pull request with this fix. | ||||
| Steps To Reproduce | Steps to reproduce
Expected resultEvery attribute row is in the export exactly once. Actual resultSome keys are in the export twice, and the same number of rows are missing. Importing the file gives a survey without these attributes. | ||||
| Tags | No tags attached. | ||||
| Bug heat | 2 | ||||
| Complete LimeSurvey version number (& build) | 7.12.1+261125 (also checked against master eb32631) | ||||
| I will donate to the project if issue is resolved | No | ||||
| Browser | not relevant (server-side export) | ||||
| Database type & version | PostgreSQL 18.7 | ||||
| Server OS (if known) | Debian 12 (Docker) | ||||
| Webserver software & version (if known) | nginx 1.22.1 with PHP-FPM | ||||
| PHP Version | 8.4.28 | ||||
| Git branch / Pull Request URL | |||||
|
Pull request with the fix: https://github.com/LimeSurvey/LimeSurvey/pull/5602 |
|
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2026-11-25 16:23 | jannik3445 | New Issue | |
| 2026-11-25 16:28 | jannik3445 | Note Added: 87960 | |
| 2026-11-25 16:28 | jannik3445 | Bug heat | 0 => 2 |
| 2026-11-25 17:21 | tibor.pacalat | Assigned To | => p_teichmann |
| 2026-11-25 17:21 | tibor.pacalat | Status | new => ready for code review |