Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Solved: 9.0.2: Unable to restore configuration from backup created with version 9.0.2
#1
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
Reply
#2
Nice catch :-)

I'll fix for upcoming 9.0.3
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
Looking at the commit history I see that the extra columns were added in commit https://github.com/moode-player/moode/co...aaae3616fa two months ago leading up to the 900 release.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#4
@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
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#5
Hi Tim,

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

Thank you! :-)
Jens
Reply
#6
Ok cool.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Forum Jump: