Project

General

Profile

Bug #2114

Depreciated PHP Functions/Warnings

Added by Jim Pingle over 7 years ago. Updated over 3 years ago.

Status:
Resolved
Priority:
Very Low
Assignee:
-
Category:
Web Interface
Target version:
-
Start date:
01/19/2012
Due date:
% Done:

0%

Estimated time:
Affected Version:
Affected Architecture:

Description

In PHP 5.3 some depreciation warnings were introduced, which we may want to tackle as they are found.

Here are some samples:


Deprecated: Function split() is deprecated in /usr/local/sbin/pfSsh.php on line 313

Deprecated: Assigning the return value of new by reference is deprecated in /etc/inc/shaper.inc on line 403

Deprecated: Assigning the return value of new by reference is deprecated in /etc/inc/shaper.inc on line 406

Deprecated: Assigning the return value of new by reference is deprecated in /etc/inc/shaper.inc on line 409

Deprecated: Assigning the return value of new by reference is deprecated in /etc/inc/shaper.inc on line 412

Deprecated: Assigning the return value of new by reference is deprecated in /etc/inc/shaper.inc on line 1376

Deprecated: Assigning the return value of new by reference is deprecated in /etc/inc/shaper.inc on line 2077

Deprecated: Assigning the return value of new by reference is deprecated in /etc/inc/shaper.inc on line 2853

Deprecated: Assigning the return value of new by reference is deprecated in /etc/inc/shaper.inc on line 3696

Deprecated: Assigning the return value of new by reference is deprecated in /etc/inc/shaper.inc on line 3916

Deprecated: Assigning the return value of new by reference is deprecated in /etc/inc/shaper.inc on line 3958

Note that you may have to turn error_reporting up to E_ALL to see these.

Since these still work now it isn't critical to do but still worth noting for the future.

Associated revisions

Revision b0c76f18 (diff)
Added by Ermal Lu├ži over 7 years ago

Ticket #2114. Remove define_syslog_variables since its deprecated and probably not needed

History

#1 Updated by Jim Pingle over 7 years ago

For the split calls, most can be made into explode.

These will need to be changed to preg_split():

etc/inc/voucher.inc:    $a_vouchers_received = split("[\t\n\r ]+",$voucher_received); 
etc/inc/voucher.inc:    $a_vouchers_received = split("[\t\n\r ]+",$voucher_received); 
usr/local/captiveportal/index.php:        $a_vouchers = split("[\t\n\r ]+",$voucher);

These can probably be changed to explode() as-is:

etc/inc/auth.inc:                               $inf_split = split(",", $inf['dn']);
etc/inc/auth.inc:               $username_split=split("\@", $username);
etc/inc/auth.inc:               $username_split=split("\\", $username);
etc/inc/auth.inc:                               $membersplit = split(",", $member);
etc/inc/auth.inc:               $username_split=split("\@", $username);
etc/inc/auth.inc:               $username_split=split("\\", $username);
etc/inc/auth.inc:       $ldac_splits = split(";", $ldapauthcont);
etc/inc/auth.inc:               $scriptName = split("/", $_SERVER["SCRIPT_FILENAME"]);
etc/inc/captiveportal.inc:              $ipfwin = split(" ", $ipfwin[0]);
etc/inc/captiveportal.inc:              $ipfwout = split(" ", $ipfwout[0]);
etc/inc/dyndns.class:                                   list($ip,$code) = split(":",$data);
etc/inc/dyndns.class:                           list($cacheIP,$cacheTime) = split(':', $contents);
etc/inc/filter.inc:             $line_error = split("\:", $rules_error);
etc/inc/filter.inc:     $addresses = split(" ", $alias);
etc/inc/filter.inc:                             $vpn_lines = split("\n", $addrlist);
etc/inc/filter.inc:                                     $vpn_address_split = split(" ", $vpn_line);
etc/inc/filter.inc:     $defined_days = split(",", $schedule);
etc/inc/filter.inc:     $tmp = split("-", $schedule);
etc/inc/filter.inc:     $schedule_days = split(",", $schedule);
etc/inc/filter.inc:     $months = split(",", $schedule);
etc/inc/pfsense-utils.inc:      $ipsplit = split('[.]', $ip);
etc/inc/pfsense-utils.inc:      $getty_split = split("\n", $gettytab);
etc/inc/pfsense-utils.inc:              $boot_config_split = split("\n", $boot_config);
etc/inc/pfsense-utils.inc:      $ttys_split = split("\n", $ttys);
etc/inc/pfsense-utils.inc:      function split($seperator, $haystack, $limit = null) {
etc/inc/pfsense-utils.inc:                              $file_contents_split = split("\n", $file_contents);
etc/inc/pfsense-utils.inc:                                              $tmp_split = split("#", $tmp);
etc/inc/pkg-utils.inc:  $pkgs = split(" ", $filename);
etc/inc/vslb.inc:               $t=split("\t", $line);
etc/inc/IPv6.inc:        $parts = str_split($bin, "16");
etc/inc/config.lib.inc:        $backups = split("\n", `cd /cf/conf/backup && ls -ltr *.xml | awk '{print \$9}'`);
etc/inc/filter_log.inc: $tmp = split("/", $rule);
etc/inc/filter_log.inc: $proto = split(" ", trim($proto[1]));
etc/inc/filter_log.inc:         $flags = split('[\, ]', $leftovers);
etc/inc/filter_log.inc:         $addr_split = split("\.", $addr);
etc/inc/filter_log.inc:                 $port_split = split("\:", $addr_split[4]);
etc/inc/filter_log.inc:         $addr = split(" ", $addr);
etc/inc/filter_log.inc:         $addr_split = split("\.", $addr);
etc/inc/upgrade_config.inc:                                     $split = split("\|", $member);
etc/ecl.php:    $slices_array = split(" ", $slices);
tmp/post_upgrade_command.php:   $files_to_process = split("\n", file_get_contents("/etc/pfSense.obsoletedfiles"));
usr/local/sbin/pfSsh.php:        $lines = split("\n", $text);
usr/local/sbin/pfSsh.php:    $command_split = split(" ", $command);
usr/local/sbin/pfSsh.php:       $playback_file_split = split("\n", $playback_file_contents);
usr/local/www/diag_dump_states.php:             $parts = split(":", $ends[0]);
usr/local/www/diag_dump_states.php:             $parts = split(":", $ends[count($ends) - 1]);
usr/local/www/wizards/setup_wizard.xml:         $ft = split("\.", $_POST['lanipaddress']);
usr/local/www/wizards/setup_wizard.xml:         $hi = split("\.", $highestip);
usr/local/www/firewall_aliases_edit.php:                                        $file_contents_split = split("\n", $file_contents);
usr/local/www/firewall_aliases_edit.php:                                                        $tmp_split = split("#", $tmp);
usr/local/www/firewall_nat.php:                                         list($dstbeginport, $dstendport) = split("-", $natent['destination']['port']);
usr/local/www/interfaces.php:                           $resetTime_a = split(" ", $resetTime);
usr/local/www/firewall_virtual_ip_edit.php:     $ip_split = split("\.", $ip);
usr/local/www/installer/installer.php:  $disk = split("\n", `/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh disk-list`);
usr/local/www/installer/installer.php:          $disks_info = split(":", $d);
usr/local/www/installer/installer.php:                  $disk_info = split("\n", `/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh disk-info {$disks_info[0]}`);
usr/local/www/installer/installer.php:                  $disk_info_split = split("=", $disk_info);
usr/local/www/installer/installer.php:                          $di_s = split("=", $di);
usr/local/www/installer/installer.php:  $disk = split("\n", `/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh disk-list`);
usr/local/www/installer/installer.php:          $disks_info = split(":", $d);
usr/local/www/installer/installer.php:          $disk_info = split("\n", `/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh disk-info {$disks_info[0]}`);
usr/local/www/installer/installer.php:                  $di_s = split("=", $di);
usr/local/www/diag_backup.php:  $base_packages = split($g['base_packages'], ",");
usr/local/www/diag_backup.php:                                  $rrd_files_var_db_rrd = split("\n",`cd /var/db/rrd && ls *.rrd`);
usr/local/www/services_dyndns.php:                                      $cached_ip_s = split(":", file_get_contents($filename));
usr/local/www/system.php:       $reqdfields = split(" ", "hostname domain");
usr/local/www/system_firmware_settings.php:     $preset_urls_split = split("\n", file_get_contents("/tmp/manifest"));
usr/local/www/system_firmware_settings.php:                                             $pus_text = split("\t", $pus);
usr/local/www/diag_dns.php:             $resolved = split("\n", $dig);
usr/local/www/diag_dns.php:                             $resolved = split("\n", $dig);
usr/local/www/wizard.php:       $field_split = split("->",$field);
usr/local/www/wizard.php:                               $field_split = split("->", $field['bindstofield']);
usr/local/www/wizard.php:                                               $enablefields_split = split(",", $opt['enablefields']);
usr/local/www/status_rrd_graph.php:                                                     $optionc = split("-", $database);
usr/local/www/status_rrd_graph.php:                                             $optionc = split("-", $database);
usr/local/www/status_rrd_graph.php:                                                             $optionc = split("-", $curdatabase);
usr/local/www/status_rrd_graph.php:                                                                     $optionc = split("-", $curdatabase);
usr/local/www/status_rrd_graph_img.php:$curif = split("-", $curdatabase);
usr/local/www/interfaces_ppps_edit.php:                                 $resetTime_a = split(" ", $resetTime);
usr/local/www/widgets/widgets/picture.widget.php:       $pic_type_s = split("\.", $config['widgets']['picturewidget_filename']);
usr/local/www/widgets/widgets/rss.widget.php:   $rss_feed_s = split(",", $config['widgets']['rssfeed']);
usr/sbin/pc-sysinstall/backend/functions-extractimage.sh:start_extract_split()

#2 Updated by Jim Pingle over 7 years ago

On a similar note, join() is simply an alias to implode() now, so it should also be safe to change all of these to implode()

etc/inc/captiveportal.inc:                      fwrite($fd, join(",", $cpent) . "\n");
etc/inc/services.inc:           mwexec("/usr/sbin/rtadvd -c {$g['varetc_path']}/rtadvd.conf " . join(" ", $rtadvdifs));
etc/inc/services.inc:                   $dnscfg .= "    option domain-name-servers " . join(",", $dhcpifconf['dnsserver']) . ";";
etc/inc/services.inc:                   $dnscfg .= "    option domain-name-servers " . join(",", $syscfg['dnsserver']) . ";";
etc/inc/services.inc:                   $dhcpdconf .= " option netbios-name-servers " . join(",", $dhcpifconf['winsserver']) . ";\n";
etc/inc/services.inc:                   $dhcpdconf .= " option ntp-servers " . join(",", $dhcpifconf['ntpserver']) . ";\n";
etc/inc/services.inc:                   join(" ", $dhcpdifs));
etc/inc/services.inc:                   $dnscfgv6 .= "  option dhcp6.name-servers " . join(",", $dhcpv6ifconf['dnsserver']) . ";";
etc/inc/services.inc:                           $dnscfgv6 .= "  option dhcp6.name-servers " . join(",", $dns_arrv6) . ";";
etc/inc/services.inc:                   $dhcpdv6conf .= "       option ntp-servers " . join(",", $dhcpv6ifconf['ntpserver']) . ";\n";
etc/inc/services.inc:                   join(" ", $dhcpdv6ifs));
etc/inc/vpn.inc:                                        $halgos = join(",", $ph2ent['hash-algorithm-option']);
etc/inc/vpn.inc:                                        $mpdconf .= "   set ipcp dns " . join(" ", $syscfg['dnsserver']) . "\n";
etc/inc/vpn.inc:                                        $mpdconf .= "   set ipcp dns " . join(" ", $syscfg['dnsserver']) . "\n";
etc/inc/vpn.inc:                                        $mpdconf .= "   set ipcp dns " . join(" ", $syscfg['dnsserver']) . "\n";
etc/inc/IPv6.inc:            $cip = ':' . join(':',$ipp) . ':';
usr/local/www/includes/functions.inc.php:       $stats = join("|", $stats);
usr/local/www/guiconfig.inc:            return join($navlevelsep, $title);
usr/local/www/guiconfig.inc:                                            $entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3)));
usr/local/www/firewall_rules_edit.php:                          $filterent['tcpflags2'] = join(",", $outoftcpflags);
usr/local/www/firewall_rules_edit.php:                                  $filterent['tcpflags1'] = join(",", $settcpflags);
usr/local/www/diag_logs_ppp.php:                                        $entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3)));
usr/local/www/diag_logs_ipsec.php:                                      $entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3)));
usr/local/www/diag_logs_vpn.php:                echo "<td class=\"listlr\" nowrap>" . htmlspecialchars(join(" ", array_slice($logent, 0, 3))) . "</td>\n";

#3 Updated by Erik Fonnesbeck over 7 years ago

A couple that were either missed or I thought just needed special consideration when changing:

This is likely intended to only match the period, using it as a character class for the regular expression, so it likely needs the brackets removed when converted to explode.
etc/inc/pfsense-utils.inc: $ipsplit = split('[.]', $ip);

Unless there is some other solution I'm not aware of, this one probably needs preg_split for the character class.
etc/inc/filter_log.inc: $flags = split('[\, ]', $leftovers);

#4 Updated by Seth Mos over 7 years ago

Thanks Erik, I just committed a patch with your suggestions.
If these changes come through ok I'll proceed with the join() changes.

The list from php.net with the deprecated functions in 5.3
http://php.net/manual/en/migration53.deprecated.php

#5 Updated by Jim Pingle over 7 years ago

Various ereg* functions are also now depreciated:
  • ereg() (use preg_match() instead)
  • ereg_replace() (use preg_replace() instead)
  • eregi() (use preg_match() with the 'i' modifier instead)

We have a few of these around as well.

etc/inc/config.inc:                     if(ereg("da0", $dmesg) == true) {
etc/inc/pfsense-utils.inc:        ereg("(Content-Length:) (.*)", $string, $regs);
etc/inc/pfsense-utils.inc:        $log = ereg_replace("\n", "\\n", $text);
etc/inc/config.console.inc:     if ((ereg("cdrom", $g['platform'])) && is_interface_mismatch())
etc/inc/smtp.inc:               if(ereg('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$domain))
etc/inc/smtp.inc:                       $output=ereg_replace("(^|\n)\\.","\\1..",ereg_replace("\r([^\n]|\$)","\r\n\\1",ereg_replace("(^|[^\r])\n","\\1\r\n",ereg_replace("\n\n|\r\r","\r\n\r\n",$data))));
etc/inc/upgrade_config.inc:                             $group_name = ereg_replace("[^A-Za-z0-9]", "", $lbpool['name'] );
usr/local/www/wizards/openvpn_wizard.inc:       return ereg('[^A-Za-z0-9 _-]', $text);
usr/local/www/includes/functions.inc.php:       $swapUsage = ereg_replace('%', "", $swapUsage);
usr/local/www/exec.php:function isBlank( $arg ) { return ereg( "^\s*$", $arg ); }
usr/local/www/pkg_edit.php:                                             ereg($rowhelperfield['fieldname'] . "_fieldvalue\[(.*)\]", $template_text, $sep);
usr/local/www/pkg_edit.php:                                                 $row_helper_data = ereg_replace("  ", $seperator, $row_helper_data);
usr/local/www/pkg_edit.php:                                                 $template_text = ereg_replace("\[" . $seperator . "\]", "", $template_text);
usr/local/www/wizard.php:                   $name = ereg_replace(" ", "", $name);
usr/local/www/wizard.php:                               $fieldname = ereg_replace(" ", "", $field['name']);
usr/local/www/wizard.php:                                                       $fieldname = ereg_replace(" ", "", $efs);

#6 Updated by Jim Pingle over 7 years ago

Looks like define_syslog_variables() was removed and has no replacement, and that is used twice:

etc/inc/captiveportal.inc:      define_syslog_variables();
etc/inc/voucher.inc:    define_syslog_variables();

From http://www.php.net/manual/en/function.define-syslog-variables.php:

Relying on this feature is highly discouraged.

#7 Updated by Chris Buechler over 3 years ago

  • Status changed from New to Resolved
  • Target version deleted (Future)

addressed long ago

Also available in: Atom PDF