Project

General

Profile

Bug #9121

PHP array reference Cleanup

Added by Jim Pingle 7 months ago. Updated 7 months ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
PHP Interpreter
Target version:
Start date:
11/15/2018
Due date:
% Done:

100%

Estimated time:
Affected Version:
2.4.4
Affected Architecture:

Description

There have been a number of PHP errors on 2.4.4 as a result of uninitialized arrays being used with references. I've gone through and cleaned up everything I could find that looked like a problem, and also cleaned up quite a bit to be consistent. I also refactored a couple places that didn't need references. This should at least eliminate any additional similar problems that we have not yet definitively identified or confirmed, while also bringing consistency to areas that were already fixed. Most of these issues were in the frontend GUI pages.

A majority of this patch is cleanup and should be a no-op, but it does need testing before it gets committed. The patch can be applied with the system patches package.

Would be nice to get this into 2.4.4-p1 but it may be too large/too late, in which case it can be kicked forward to 2.4.5. In that case we should at least pull in the changes that are needed to address potential PHP issues: Fixes to the load balancer pages (virtual server, pools, status pages, widget), NTP pages, user manager password change page (for low priv users), xmlrpc voucher handling.

The following files are modified by the attached patch:

  • src/etc/inc/auth.inc
  • src/etc/inc/easyrule.inc
  • src/etc/inc/filter.inc
  • src/etc/inc/gwlb.inc
  • src/etc/inc/interfaces.inc
  • src/etc/inc/interfaces_fast.inc
  • src/etc/inc/itemid.inc
  • src/etc/inc/pfsense-utils.inc
  • src/etc/inc/pkg-utils.inc
  • src/etc/inc/priv.inc
  • src/etc/inc/service-utils.inc
  • src/etc/inc/services.inc
  • src/etc/inc/shaper.inc
  • src/etc/inc/system.inc
  • src/etc/inc/upgrade_config.inc
  • src/etc/inc/util.inc
  • src/etc/phpshellsessions/disablecarp
  • src/etc/phpshellsessions/enablecarp
  • src/etc/rc.initial.setlanip
  • src/usr/local/www/diag_dns.php
  • src/usr/local/www/firewall_aliases.php
  • src/usr/local/www/firewall_aliases_edit.php
  • src/usr/local/www/firewall_aliases_import.php
  • src/usr/local/www/firewall_nat.php
  • src/usr/local/www/firewall_nat_edit.php
  • src/usr/local/www/firewall_rules.php
  • src/usr/local/www/firewall_rules_edit.php
  • src/usr/local/www/firewall_virtual_ip.php
  • src/usr/local/www/firewall_virtual_ip_edit.php
  • src/usr/local/www/interfaces.php
  • src/usr/local/www/interfaces_bridge.php
  • src/usr/local/www/interfaces_bridge_edit.php
  • src/usr/local/www/interfaces_gif.php
  • src/usr/local/www/interfaces_gif_edit.php
  • src/usr/local/www/interfaces_gre.php
  • src/usr/local/www/interfaces_gre_edit.php
  • src/usr/local/www/interfaces_groups.php
  • src/usr/local/www/interfaces_groups_edit.php
  • src/usr/local/www/interfaces_lagg.php
  • src/usr/local/www/interfaces_lagg_edit.php
  • src/usr/local/www/interfaces_ppps_edit.php
  • src/usr/local/www/interfaces_vlan.php
  • src/usr/local/www/interfaces_vlan_edit.php
  • src/usr/local/www/interfaces_wireless.php
  • src/usr/local/www/interfaces_wireless_edit.php
  • src/usr/local/www/load_balancer_monitor.php
  • src/usr/local/www/load_balancer_monitor_edit.php
  • src/usr/local/www/load_balancer_pool.php
  • src/usr/local/www/load_balancer_pool_edit.php
  • src/usr/local/www/load_balancer_setting.php
  • src/usr/local/www/load_balancer_virtual_server.php
  • src/usr/local/www/load_balancer_virtual_server_edit.php
  • src/usr/local/www/pkg.php
  • src/usr/local/www/pkg_edit.php
  • src/usr/local/www/services_acb_settings.php
  • src/usr/local/www/services_captiveportal.php
  • src/usr/local/www/services_captiveportal_filemanager.php
  • src/usr/local/www/services_captiveportal_hostname.php
  • src/usr/local/www/services_captiveportal_hostname_edit.php
  • src/usr/local/www/services_captiveportal_ip.php
  • src/usr/local/www/services_captiveportal_ip_edit.php
  • src/usr/local/www/services_captiveportal_mac.php
  • src/usr/local/www/services_captiveportal_mac_edit.php
  • src/usr/local/www/services_captiveportal_vouchers.php
  • src/usr/local/www/services_captiveportal_vouchers_edit.php
  • src/usr/local/www/services_captiveportal_zones.php
  • src/usr/local/www/services_captiveportal_zones_edit.php
  • src/usr/local/www/services_checkip.php
  • src/usr/local/www/services_checkip_edit.php
  • src/usr/local/www/services_dhcp.php
  • src/usr/local/www/services_dhcp_edit.php
  • src/usr/local/www/services_dhcpv6.php
  • src/usr/local/www/services_dhcpv6_edit.php
  • src/usr/local/www/services_dnsmasq.php
  • src/usr/local/www/services_dnsmasq_domainoverride_edit.php
  • src/usr/local/www/services_dnsmasq_edit.php
  • src/usr/local/www/services_dyndns.php
  • src/usr/local/www/services_dyndns_edit.php
  • src/usr/local/www/services_igmpproxy.php
  • src/usr/local/www/services_igmpproxy_edit.php
  • src/usr/local/www/services_ntpd.php
  • src/usr/local/www/services_ntpd_acls.php
  • src/usr/local/www/services_ntpd_gps.php
  • src/usr/local/www/services_ntpd_pps.php
  • src/usr/local/www/services_pppoe.php
  • src/usr/local/www/services_pppoe_edit.php
  • src/usr/local/www/services_rfc2136.php
  • src/usr/local/www/services_rfc2136_edit.php
  • src/usr/local/www/services_unbound.php
  • src/usr/local/www/services_unbound_acls.php
  • src/usr/local/www/services_unbound_domainoverride_edit.php
  • src/usr/local/www/services_unbound_host_edit.php
  • src/usr/local/www/services_wol.php
  • src/usr/local/www/services_wol_edit.php
  • src/usr/local/www/status_captiveportal.php
  • src/usr/local/www/status_captiveportal_expire.php
  • src/usr/local/www/status_captiveportal_test.php
  • src/usr/local/www/status_captiveportal_voucher_rolls.php
  • src/usr/local/www/status_captiveportal_vouchers.php
  • src/usr/local/www/status_carp.php
  • src/usr/local/www/status_ipsec.php
  • src/usr/local/www/status_lb_pool.php
  • src/usr/local/www/status_lb_vs.php
  • src/usr/local/www/system_advanced_admin.php
  • src/usr/local/www/system_advanced_sysctl.php
  • src/usr/local/www/system_authservers.php
  • src/usr/local/www/system_camanager.php
  • src/usr/local/www/system_certmanager.php
  • src/usr/local/www/system_crlmanager.php
  • src/usr/local/www/system_gateway_groups.php
  • src/usr/local/www/system_gateway_groups_edit.php
  • src/usr/local/www/system_gateways.php
  • src/usr/local/www/system_gateways_edit.php
  • src/usr/local/www/system_groupmanager.php
  • src/usr/local/www/system_groupmanager_addprivs.php
  • src/usr/local/www/system_hasync.php
  • src/usr/local/www/system_routes.php
  • src/usr/local/www/system_routes_edit.php
  • src/usr/local/www/system_user_settings.php
  • src/usr/local/www/system_usermanager.php
  • src/usr/local/www/system_usermanager_passwordmg.php
  • src/usr/local/www/vpn_ipsec.php
  • src/usr/local/www/vpn_ipsec_keys.php
  • src/usr/local/www/vpn_ipsec_keys_edit.php
  • src/usr/local/www/vpn_ipsec_mobile.php
  • src/usr/local/www/vpn_ipsec_phase1.php
  • src/usr/local/www/vpn_ipsec_phase2.php
  • src/usr/local/www/vpn_l2tp.php
  • src/usr/local/www/vpn_l2tp_users.php
  • src/usr/local/www/vpn_l2tp_users_edit.php
  • src/usr/local/www/vpn_openvpn_client.php
  • src/usr/local/www/vpn_openvpn_csc.php
  • src/usr/local/www/vpn_openvpn_server.php
  • src/usr/local/www/widgets/widgets/captive_portal_status.widget.php
  • src/usr/local/www/widgets/widgets/load_balancer_status.widget.php
  • src/usr/local/www/wizards/openvpn_wizard.inc
  • src/usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc
  • src/usr/local/www/wizards/traffic_shaper_wizard_multi_all.inc
  • src/usr/local/www/xmlrpc.php
php-array-refs.diff (120 KB) php-array-refs.diff Jim Pingle, 11/15/2018 10:04 AM

Associated revisions

Revision c6c398c6 (diff)
Added by Jim Pingle 7 months ago

Fix #9121: Initialize arrays to prevent PHP 7 errors

Revision ea0dd417 (diff)
Added by Jim Pingle 7 months ago

Fix #9121: Initialize arrays to prevent PHP 7 errors

History

#1 Updated by James Dekker 7 months ago

Tested on 2.4.5.a.20181114.1947, hit the following php error with a DNS forwarder domain override in place:

[15-Nov-2018 23:37:00 Etc/UTC] PHP Warning:  Use of undefined constant _msdcs - assumed '_msdcs' (this will throw an Error in a future version of PHP) in /usr/local/www/services_dnsmasq_domainoverride_edit.php on line 69

also hit the following php error with captive portal and vouchers configured:

[15-Nov-2018 19:32:23 America/New_York] PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /etc/rc.filter_synchronize on line 356

Tested each page that contains the php files listed above, created items, saved the settings, edited the settings, saved them again, deleted them. Did my best to recreate the behavior of a user configuring each of the respective pages.

#2 Updated by Steve Beaver 7 months ago

Those two error appear to be unrelated to the original issue. I have pushed a fix for them both.

#3 Updated by Jim Pingle 7 months ago

  • Status changed from New to Feedback
  • % Done changed from 0 to 100

#4 Updated by James Dekker 7 months ago

Tested the DNS forwarder configuration that threw the php issue (https://redmine.pfsense.org/issues/9121#note-1), on 2.4.5.a.20181120.0754 gitsync'd to master, could not reproduce.

Tested the Captive Portal configuration that threw the php error (https://redmine.pfsense.org/issues/9121#note-1), on 2.4.5.a.20181120.0754 gitsync'd to master, could not reproduce.

#5 Updated by Steve Beaver 7 months ago

  • Status changed from Feedback to Resolved

Also available in: Atom PDF