PHP Error when loading Backup & Restore page
-
Discovered a bug in 23.01.b.20230106.0600
Seems there is an issue enumerating the packages installed when loading the Backup & Restore page when there are no packages installed on the system.
Steps to reproduce
- Have no packages installed.
- Install a package (e.g. System_patches)
- Remove the package - you now have no packages installed on the system again.
- Click on Diagnostics > Backup & Restore. You should be met with the below error message.
PHP ERROR: Type: 1, File: /usr/local/www/diag_backup.php, Line: 280, Message: Uncaught TypeError: Cannot access offset of type string on string in /usr/local/www/diag_backup.php:280 Stack trace: #0 {main} thrown @ 2023-01-14 12:36:28
Found a temp fix can be done by editing the /cf/conf/config.xml and removing the following empty tags.
<installedpackages> </installedpackages>
As such seems to be some kind of enumeration error when there are no packages installed on the system, by removing the tags you negate the checks to load the Reinstall packages section of the Backup & Restore page so it loads fine.
-
@chickendog Can you upgrade to the current release? Your build appears to be more than a week old (a buildstamp of Jan 6, 2023 at 6am).
-
@rcoleman-netgate Yes but that is the latest build available on the 23.01 branch as of today. I think they freezed it?
-
@chickendog It's definitely possible - I don't follow the engineering progress closely enough to know for certain one way or the other.
-
@rcoleman-netgate Dev said so here https://forum.netgate.com/post/1080237
-
@chickendog Ahh, yeah, Jim's one of our engineers. I am doing other testing internally so I don't get to see the public build numbers. We are in our own bubble here in TAC :D
-
Oddly enough I can't reproduce the PHP error but I can see where it would happen (and should happen). I've got a change that should fix it, though:
https://redmine.pfsense.org/issues/13876
index 18bb573b0c..21d1847e09 100644 --- a/src/usr/local/www/diag_backup.php +++ b/src/usr/local/www/diag_backup.php @@ -268,10 +268,12 @@ $section->add($group); $form->add($section); -if (($config['installedpackages']['package'] != "") || (is_subsystem_dirty("packagelock"))) { +$has_installed_packages = !empty(config_get_path('installedpackages/package', [])); + +if ($has_installed_packages || (is_subsystem_dirty("packagelock"))) { $section = new Form_Section('Package Functions'); - if ($config['installedpackages']['package'] != "") { + if ($has_installed_packages) { $group = new Form_Group(''); // Note: ID attribute of each element created is to be unique. Not being used, suppressing it. $group->add(new Form_Button(