View Issue Details

This bug affects 1 person(s).
 20
IDProjectCategoryView StatusLast Update
17568Bug reportsOtherpublic2021-11-10 07:42
Reporterjr_limesurvery_statconsult_de Assigned Top_teichmann  
PrioritynoneSeverityblock 
Status closedResolutionfixed 
Product Version5.x 
Summary17568: PHP Error[2]: Invalid argument supplied for foreach() ... updatedb_helper.php at line 4954 / function decryptArchivedTables450
Description

We're running 5.0.8 ...
... upgrading to 5.0.9... 5.0.10 was fine - but fails when trying to update to 5.0.11 (and 5.1.5 too):

php ls5/application/commands/console.php updatedb
Update pgsql:host=localhost;port=5432;user=aaa;password=secret;dbname=aaa; with prefix :lime_ from 449 to 451
PHP Error[2]: Invalid argument supplied for foreach()
in file /var/www/virtual_hosts/bbb/docs/limesurvey5.0.11_210727/application/helpers/update/updatedb_helper.php at line 4954
#0 /var/www/virtual_hosts/bbb/docs/limesurvey5.0.11_210727/application/helpers/update/updatedb_helper.php(4757): decryptArchivedTables450()
#1 /var/www/virtual_hosts/bbb/docs/limesurvey5.0.11_210727/application/helpers/update/updatedb_helper.php(4636): updateEncryptedValues450()
#2 /var/www/virtual_hosts/bbb/docs/limesurvey5.0.11_210727/application/commands/UpdateDbCommand.php(45): db_upgrade_all()
#3 /var/www/virtual_hosts/bbb/docs/limesurvey5.0.11_210727/framework/console/CConsoleCommandRunner.php(71): UpdateDBCommand->run()
#4 /var/www/virtual_hosts/bbb/docs/limesurvey5.0.11_210727/framework/console/CConsoleApplication.php(92): CConsoleCommandRunner->run()
#5 /var/www/virtual_hosts/bbb/docs/limesurvey5.0.11_210727/framework/base/CApplication.php(185): ConsoleApplication->processRequest()
#6 /var/www/virtual_hosts/bbb/docs/limesurvey5.0.11_210727/application/commands/console.php(69): ConsoleApplication->run()

so this was obviously introduced with:

https://github.com/LimeSurvey/LimeSurvey/commit/1265a93cfc8074b278e50386d17d4276f1550114#diff-fac7e21d70e934b24d9330f951f13c5df1badba6f41fa52c894364fb09db4d8c

Steps To Reproduce

Always reproducible ... try updating pre 5.0.11 versions to 5.0.11 or newer.

Additional Information

possibly somewhat related to what someone reported here too (at least syntax related):

https://bugs.limesurvey.org/view.php?id=17476

TagsNo tags attached.
Bug heat20
Complete LimeSurvey version number (& build)5.0.10 / 210723
I will donate to the project if issue is resolvedNo
BrowserFF
Database type & versionPostgreSQL 11 / 11.12-0+deb10u1
Server OS (if known)Debian Buster x64 / 10.10
Webserver software & version (if known)Apache / 2.4.38-3+deb10u5
PHP VersionPHP7 / 7.3.29-1~deb10u1

Relationships

duplicate of 17476 closedp_teichmann error Invalid argument supplied for foreach() in tokens.php(2584) when I reimport old Tokens 
has duplicate 17576 closedp_teichmann PHP Error[8]: Undefined index: type ... updatedb_helper.php at line 4708 

Users monitoring this issue

There are no users monitoring this issue.

Activities

ollehar

ollehar

2021-09-03 14:04

administrator   ~66312

Please try with latest version Release 5.1.5

jr_limesurvery_statconsult_de

jr_limesurvery_statconsult_de

2021-09-03 14:42

reporter   ~66314

Last edited: 2021-09-03 14:50

We did try that ofcourse too (see above) - but just for completeness:

Update pgsql:host=localhost;port=5432;user=aaa;password=secret;dbname=aaa; with prefix :lime_ from 449 to 471
PHP Error[2]: Invalid argument supplied for foreach()
in file /var/www/virtual_hosts/bbb/docs/limesurvey5.1.5_210830/application/helpers/update/updatedb_helper.php at line 5131
#0 /var/www/virtual_hosts/bbb/docs/limesurvey5.1.5_210830/application/helpers/update/updatedb_helper.php(4937): decryptArchivedTables450()
#1 /var/www/virtual_hosts/bbb/docs/limesurvey5.1.5_210830/application/helpers/update/updatedb_helper.php(4653): updateEncryptedValues450()
#2 /var/www/virtual_hosts/bbb/docs/limesurvey5.1.5_210830/application/commands/UpdateDbCommand.php(45): db_upgrade_all()
#3 /var/www/virtual_hosts/bbb/docs/limesurvey5.1.5_210830/framework/console/CConsoleCommandRunner.php(71): UpdateDBCommand->run()
#4 /var/www/virtual_hosts/bbb/docs/limesurvey5.1.5_210830/framework/console/CConsoleApplication.php(92): CConsoleCommandRunner->run()
#5 /var/www/virtual_hosts/bbb/docs/limesurvey5.1.5_210830/framework/base/CApplication.php(185): ConsoleApplication->processRequest()
#6 /var/www/virtual_hosts/bbb/docs/limesurvey5.1.5_210830/application/commands/console.php(69): ConsoleApplication->run()

the function where it breaks did not change in between...

ollehar

ollehar

2021-09-03 14:44

administrator   ~66315

Last edited: 2021-09-03 14:50

Are you running this with debug = 2 or = 0 in config.php?

jr_limesurvery_statconsult_de

jr_limesurvery_statconsult_de

2021-09-03 14:49

reporter   ~66316

Last edited: 2021-09-03 14:50

this is with debug = 0 in config.php

ollehar

ollehar

2021-09-03 14:51

administrator   ~66317

Thank you.

jr_limesurvery_statconsult_de

jr_limesurvery_statconsult_de

2021-09-03 15:19

reporter   ~66319

FWIW ... var_dump($archivedTableSettingsArray); added just before the foreach loop - gives:

array(2) {
["enabled"]=>
string(1) "Y"
["columns"]=>
array(3) {
["firstname"]=>
string(1) "N"
["lastname"]=>
string(1) "N"
["email"]=>
string(1) "N"
}
}
array(0) {
}
NULL

p_teichmann

p_teichmann

2021-09-03 15:50

administrator   ~66321

A fix for this is already in progress as part of another task, we will give an update when it’s ready.

p_teichmann

p_teichmann

2021-09-07 10:28

administrator   ~66374

see https://bugs.limesurvey.org/view.php?id=17476

c_schmitz

c_schmitz

2021-09-07 15:22

administrator   ~66375

Last edited: 2021-09-07 15:22

Message from reporter:

just checked with 5.1.7.

It unfortunately still does not work when it comes to updating the database - it now emits:

php limesurvey5.1.7210908/application/commands/console.php updatedb
Update pgsql:host=localhost;port=5432;user=aaa;password=secret;dbname=aaa; with prefix :lime
from 449 to 472
PHP Error[8]: Undefined index: type
in file /var/www/virtual_hosts/bbb/docs/limesurvey5.1.7_210908/application/helpers/update/updatedb_helper.php at line 4708
#0 /var/www/virtual_hosts/bbb/docs/limesurvey5.1.7_210908/application/commands/UpdateDbCommand.php(45): db_upgrade_all()
#1 /var/www/virtual_hosts/bbb/docs/limesurvey5.1.7_210908/framework/console/CConsoleCommandRunner.php(71): UpdateDBCommand->run()
#2 /var/www/virtual_hosts/bbb/docs/limesurvey5.1.7_210908/framework/console/CConsoleApplication.php(92): CConsoleCommandRunner->run()
#3 /var/www/virtual_hosts/bbb/docs/limesurvey5.1.7_210908/framework/base/CApplication.php(185): ConsoleApplication->processRequest()
#4 /var/www/virtual_hosts/bbb/docs/limesurvey5.1.7_210908/application/commands/console.php(69): ConsoleApplication->run()

c_schmitz

c_schmitz

2021-09-08 09:58

administrator   ~66392

New version released.

c_schmitz

c_schmitz

2021-09-09 08:37

administrator   ~66412

Message from reporter:

Trying 5.1.9 it now emits:

php ls5/application/commands/console.php updatedb
Update pgsql:host=localhost;port=5432;user=aaa;password=secret;dbname=aaa; with prefix :lime_ from 449 to 472
PHP Error[8]: Undefined offset: 0
in file /var/www/virtual_hosts/bbb/docs/limesurvey5.1.9_210912/application/helpers/update/updatedb_helper.php at line 5265
#0 /var/www/virtual_hosts/bbb/docs/limesurvey5.1.9_210912/application/helpers/update/updatedb_helper.php(5023): decryptArchivedTables450()
#1 /var/www/virtual_hosts/bbb/docs/limesurvey5.1.9_210912/application/helpers/update/updatedb_helper.php(4714): updateEncryptedValues450()
#2 /var/www/virtual_hosts/bbb/docs/limesurvey5.1.9_210912/application/commands/UpdateDbCommand.php(45): db_upgrade_all()
#3 /var/www/virtual_hosts/bbb/docs/limesurvey5.1.9_210912/framework/console/CConsoleCommandRunner.php(71): UpdateDBCommand->run()
#4 /var/www/virtual_hosts/bbb/docs/limesurvey5.1.9_210912/framework/console/CConsoleApplication.php(92): CConsoleCommandRunner->run()
#5 /var/www/virtual_hosts/bbb/docs/limesurvey5.1.9_210912/framework/base/CApplication.php(185): ConsoleApplication->processRequest()
#6 /var/www/virtual_hosts/bbb/docs/limesurvey5.1.9_210912/application/commands/console.php(69): ConsoleApplication->run()

jr_limesurvery_statconsult_de

jr_limesurvery_statconsult_de

2021-09-09 21:39

reporter   ~66440

Providing the database would require me to deal with things that need to be anonymized before... so I'd like to prevent this.

However - I tried debugging it further and I guess I've found something (application/helpers/update/updatedb_helper.php):
[added some print_r() just before line 5265]

print_r($archivedTableSettings);
Array
(
[id] => 2
[survey_id] => 815967
[user_id] => 1
[tbl_name] => old_survey_815967_20210628225359
[tbl_type] => response
[created] => 2021-06-28 22:53:59.61645
[properties] => []
[attributes] =>
)

print_r($archivedTableSettingsProperties);
Array
(
)

So - $archivedTableSettingsProperties exists - but it does not have an index 0 (it's literally empty) - so it's at least clear why this error comes up.

Tried this now:

diff -Naur limesurvey5.1.9_210912.dist/application/helpers/update/updatedb_helper.php limesurvey5.1.9_210912/application/helpers/update/updatedb_helper.php
--- limesurvey5.1.9_210912.dist/application/helpers/update/updatedb_helper.php 2021-09-08 11:08:34.000000000 +0200
+++ limesurvey5.1.9_210912/application/helpers/update/updatedb_helper.php 2021-09-09 21:31:27.312118339 +0200
@@ -5213,7 +5213,7 @@
// recrypt tokens
if ($archivedTableSettings['tbl_type'] === 'token') {
// skip if the encryption status is unknown

  • if (isset($archivedTableSettingsProperties) && $archivedTableSettingsProperties[0] !== 'unknown') {
  • if (isset($archivedTableSettingsProperties[0]) && $archivedTableSettingsProperties[0] !== 'unknown') {
    $tokenencryptionoptions = $archivedTableSettingsProperties;

             // default attributes

    @@ -5262,7 +5262,7 @@
    }

     // recrypt responses // skip if the encryption status is unknown
  • if ($archivedTableSettings['tbl_type'] === 'response' && isset($archivedTableSettingsProperties) && $archivedTableSettingsProperties[0] !== 'unknown') {
  • if ($archivedTableSettings['tbl_type'] === 'response' && isset($archivedTableSettingsProperties[0]) && $archivedTableSettingsProperties[0] !== 'unknown') {
    $responsesCount = $oDB->createCommand()
    ->select('count(*)')
    ->from("{{{$archivedTableSettings['tbl_name']}}}")

and I do come past this error now... with:

php limesurvey5.1.9210912/application/commands/console.php updatedb
Update pgsql:host=localhost;port=5432;user=ls5user;password=ls5pass;dbname=ls5db; with prefix :lime
from 449 to 472
Database has been successfully upgraded to version 472

Which looks good to me - at least a first glance.

Questions:
A) can this $archivedTableSettingsProperties be really that empty? Or is it maybe an errorneous result of something else not beeing OK?
B) is this test patch correct at all?

thanks...

jr_limesurvery_statconsult_de

jr_limesurvery_statconsult_de

2021-09-30 15:49

reporter   ~66694

Any chance that someone still could have a look into this?! I just tried 5.1.14 too - but the issue is still the same.
Thankyou!

jr_limesurvery_statconsult_de

jr_limesurvery_statconsult_de

2021-09-30 16:59

reporter   ~66697

FWIW... I just saw another recent commit which seems to deal with something similiar when upgrading an older db to 450.
Slightly different (better) approach to fix - but it's too about an obivously empty archivedTableSettingsProperties.

https://github.com/LimeSurvey/LimeSurvey/commit/20991add684a0a717deda5d66394b3382d5ff3c3

p_teichmann

p_teichmann

2021-10-11 12:22

administrator   ~66824

Hello,
we had internally marked this issue already solved, there were multiple tickets with the same problem and this one got lost on the way. We didn't get any further error reports regarding this issue.
As you have noticed, the fix that you linked should have resolved your issue. Can you confirm that this issue is still affecting you? And if yes, would be great if you could provide as with an updated error.

As to your questions:
A) yes, the value can be empty
B) the patch back then was incomplete, which is why we provided the fix that you linked

p_teichmann

p_teichmann

2021-10-11 17:24

administrator   ~66829

Last edited: 2021-10-11 17:25

Just confirmed that this issue exists, we will update the code accordingly. The reason we no longer got bug reports is that if you are running in "config=0" mode the error will be ignored, which is fine in this case. However, the proper fix would be to replace "$archivedTableSettingsProperties[0]" with "reset($archivedTableSettingsProperties)", since we are working with a mix of normal arrays and associative once.

If you want it to work before update, replace the mentioned code accordingly or change debug mode to 0

jr_limesurvery_statconsult_de

jr_limesurvery_statconsult_de

2021-10-20 20:51

reporter   ~66882

Dear all,
just to be sure - the fix you're talking about was not yet committed - isn't it?
I'm asking, because the most recent release (5.1.16) still bails out there:

php limesurvey5.1.16211020/application/commands/console.php updatedb
Update pgsql:host=localhost;port=5432;user=ls5;password=x;dbname=ls5; with prefix :lime
from 449 to 475
PHP Error[8]: Undefined offset: 0
in file /var/www/virtual_hosts/x/docs/limesurvey5.1.16_211020/application/helpers/update/updatedb_helper.php at line 5232
#0 /var/www/virtual_hosts/x/docs/limesurvey5.1.16_211020/application/helpers/update/updatedb_helper.php(5039): decryptArchivedTables450()
#1 /var/www/virtual_hosts/x/docs/limesurvey5.1.16_211020/application/helpers/update/updatedb_helper.php(4673): updateEncryptedValues450()
#2 /var/www/virtual_hosts/x/docs/limesurvey5.1.16_211020/application/commands/UpdateDbCommand.php(46): db_upgrade_all()
#3 /var/www/virtual_hosts/x/docs/limesurvey5.1.16_211020/framework/console/CConsoleCommandRunner.php(71): UpdateDBCommand->run()
#4 /var/www/virtual_hosts/x/docs/limesurvey5.1.16_211020/framework/console/CConsoleApplication.php(92): CConsoleCommandRunner->run()
#5 /var/www/virtual_hosts/x/docs/limesurvey5.1.16_211020/framework/base/CApplication.php(185): ConsoleApplication->processRequest()
#6 /var/www/virtual_hosts/x/docs/limesurvey5.1.16_211020/application/commands/console.php(69): ConsoleApplication->run()

FWIW - is there anything I can provide to get things sorted - apart from the whole database...?!
Maybe a dump of a specific table or whatever - please name it.
Thankyou!

ollehar

ollehar

2021-10-20 20:54

administrator   ~66883

Unfortunately, the fixed was never merged due to missing code review. We hope it will be included on Monday's release. Sorry for the delay.

p_teichmann

p_teichmann

2021-10-25 11:56

administrator   ~66922

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

Related Changesets

LimeSurvey: master 37c9bee2

2021-10-25 11:55:16

p_teichmann

Details Diff
Fixed issue 17568: database update 450 fails Affected Issues
17568
mod - application/helpers/update/updatedb_helper.php Diff File

Issue History

Date Modified Username Field Change
2021-09-03 14:02 jr_limesurvery_statconsult_de New Issue
2021-09-03 14:04 ollehar Assigned To => ollehar
2021-09-03 14:04 ollehar Status new => feedback
2021-09-03 14:04 ollehar Note Added: 66312
2021-09-03 14:04 ollehar Bug heat 0 => 2
2021-09-03 14:42 jr_limesurvery_statconsult_de Note Added: 66314
2021-09-03 14:42 jr_limesurvery_statconsult_de Bug heat 2 => 4
2021-09-03 14:42 jr_limesurvery_statconsult_de Status feedback => assigned
2021-09-03 14:44 ollehar Note Added: 66315
2021-09-03 14:47 c_schmitz Status assigned => feedback
2021-09-03 14:49 jr_limesurvery_statconsult_de Note Added: 66316
2021-09-03 14:49 jr_limesurvery_statconsult_de Status feedback => assigned
2021-09-03 14:50 ollehar Sync to Zoho Project => |Yes|
2021-09-03 14:51 ollehar Note Added: 66317
2021-09-03 15:19 jr_limesurvery_statconsult_de Note Added: 66319
2021-09-03 15:50 p_teichmann Note Added: 66321
2021-09-03 15:50 p_teichmann Bug heat 4 => 6
2021-09-07 10:12 p_teichmann Relationship added duplicate of 17476
2021-09-07 10:28 p_teichmann Assigned To ollehar => p_teichmann
2021-09-07 10:28 p_teichmann Status assigned => resolved
2021-09-07 10:28 p_teichmann Resolution open => duplicate
2021-09-07 10:28 p_teichmann Note Added: 66374
2021-09-07 15:21 c_schmitz Status resolved => feedback
2021-09-07 15:21 c_schmitz Resolution duplicate => reopened
2021-09-07 15:22 c_schmitz Relationship added has duplicate 17576
2021-09-07 15:22 c_schmitz Bug heat 6 => 12
2021-09-07 15:22 c_schmitz Note Added: 66375
2021-09-07 15:22 c_schmitz Bug heat 12 => 14
2021-09-07 15:22 c_schmitz Note Edited: 66375
2021-09-07 15:23 c_schmitz Status feedback => assigned
2021-09-08 09:58 c_schmitz Status assigned => resolved
2021-09-08 09:58 c_schmitz Resolution reopened => fixed
2021-09-08 09:58 c_schmitz Note Added: 66392
2021-09-08 09:59 c_schmitz Status resolved => closed
2021-09-09 08:37 c_schmitz Bug heat 14 => 20
2021-09-09 08:37 c_schmitz Note Added: 66412
2021-09-09 08:37 c_schmitz Status closed => feedback
2021-09-09 08:37 c_schmitz Resolution fixed => reopened
2021-09-09 21:39 jr_limesurvery_statconsult_de Note Added: 66440
2021-09-09 21:39 jr_limesurvery_statconsult_de Status feedback => assigned
2021-09-30 15:49 jr_limesurvery_statconsult_de Note Added: 66694
2021-09-30 16:59 jr_limesurvery_statconsult_de Note Added: 66697
2021-10-11 12:22 p_teichmann Note Added: 66824
2021-10-11 17:24 p_teichmann Note Added: 66829
2021-10-11 17:25 p_teichmann Note Edited: 66829
2021-10-19 16:31 galads Status assigned => feedback
2021-10-20 20:51 jr_limesurvery_statconsult_de Note Added: 66882
2021-10-20 20:51 jr_limesurvery_statconsult_de Status feedback => assigned
2021-10-20 20:54 ollehar Note Added: 66883
2021-10-25 11:56 p_teichmann Changeset attached => LimeSurvey master 37c9bee2
2021-10-25 11:56 p_teichmann Note Added: 66922
2021-10-25 11:56 p_teichmann Resolution reopened => fixed
2021-11-10 07:34 c_schmitz Status assigned => resolved
2021-11-10 07:34 c_schmitz Resolution fixed => duplicate
2021-11-10 07:35 c_schmitz Resolution duplicate => fixed
2021-11-10 07:42 c_schmitz Status resolved => closed