Moode Forum
[SOLVED] 9.0.2: Unable to restore configuration from backup created with version 9.0.2 - Printable Version

+- Moode Forum (https://moodeaudio.org/forum)
+-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7)
+--- Thread: [SOLVED] 9.0.2: Unable to restore configuration from backup created with version 9.0.2 (/showthread.php?tid=6621)



9.0.2: Unable to restore configuration from backup created with version 9.0.2 - jenzd - 06-16-2024

Hi all,

I think I have spotted a bug in the "Config and Prefs" restore function of Moode 9.0.2 (the part which restores the configuration from the file moodecfg.ini):

When I try to restore a backup created with Moode 9.0.2 the process fails at the stage where the WLAN configuration is processed. The log file /var/log/moode_autocfg.log then reads:


Code:
20240616 160923 autocfg: - Network (wlan0)
20240616 160923 autocfg: wlanssid: [...]
20240616 160923 autocfg: wlanpwd:
20240616 160923 autocfg: wlanuuid: [...]
20240616 160923 autocfg: wlanmethod: dhcp
20240616 160923 autocfg: wlanipaddr:
20240616 160923 autocfg: wlannetmask: 255.255.255.0
20240616 160923 autocfg: wlangateway:
20240616 160923 autocfg: wlanpridns:
20240616 160923 autocfg: wlansecdns:
20240616 160923 autocfg: wlanpsk: [...]
20240616 160923 autocfg: wlancountry: DE
20240616 160923 autocfg: ssid_ssid: Array
20240616 160923 autocfg: ssid_uuid: Array
20240616 160923 autocfg: ssid_psk: Array
20240616 160923 autocfg: Caught exception: SQLSTATE[HY000]: General error: 1 table cfg_ssid has 10 columns but 4 values were supplied
20240616 160923 autocfg: Configuration file deleted
20240616 160923 autocfg: Auto-configure complete
20240616 160923 autocfg: System restarted

Note the part with the SQL exception when the process tries to insert new values into the table CFG_SSID. Issue seems to be that this table now has 10 columns (used to be just 4 in older versions of Moode), but just 4 are provided in the INSERT statement.

If I understand the code correctly this is due to line 266 of the file /var/www/inc/autocfg.php indeed providing too few columns for the table:

Code:
            for ($i = 0; $i < $count; $i++) {
                $value = "\"" . $values['ssid_ssid'][$i] . "\", \""  .
                    $values['ssid_uuid'][$i]    . "\", \"" . $values['ssid_psk'][$i] . "\"";
                sqlInsert('cfg_ssid', $dbh, $value);
            }

while the table layout returned by moodeutl -q "pragma table_info(cfg_ssid)" would be

Code:
0|id|INTEGER|0||1
1|ssid|CHAR (32)|0||0
2|uuid|CHAR (32)|0||0
3|psk|CHAR (32)|0||0
4|method|CHAR (32)|0||0
5|ipaddr|CHAR (32)|0||0
6|netmask|CHAR (32)|0||0
7|gateway|CHAR (32)|0||0
8|pridns|CHAR (32)|0||0
9|secdns|CHAR (32)|0||0

It is strange, however, that restoring a backup created with Moode 8.3.9 works in 9.0.2 without any errors. May be the older format is handled by a different function?

Best regards
Jens


RE: 9.0.2: Unable to restore configuration from backup created with version 9.0.2 - Tim Curtis - 06-17-2024

Nice catch :-)

I'll fix for upcoming 9.0.3


RE: 9.0.2: Unable to restore configuration from backup created with version 9.0.2 - Tim Curtis - 06-17-2024

Looking at the commit history I see that the extra columns were added in commit https://github.com/moode-player/moode/commit/5095b571edfc2e07ef82755e13035faaae3616fa two months ago leading up to the 900 release.


RE: 9.0.2: Unable to restore configuration from backup created with version 9.0.2 - Tim Curtis - 06-17-2024

@jenzd, give this a try

Code:
sudo wget -q https://raw.githubusercontent.com/moode-player/moode/develop/www/inc/autocfg.php -O /var/www/inc/autocfg.php



RE: 9.0.2: Unable to restore configuration from backup created with version 9.0.2 - jenzd - 06-17-2024

Hi Tim,

The patch works. Tested with both 9.0.2 and 8.3.9 backup files.

Thank you! :-)
Jens


RE: 9.0.2: Unable to restore configuration from backup created with version 9.0.2 - Tim Curtis - 06-17-2024

Ok cool.