Project

General

Profile

Actions

Bug #13562

closed

HAProxy PHP error on upgrade to PHP8.1 update

Added by Robert Johnston 4 months ago. Updated 2 months ago.

Status:
Duplicate
Priority:
Normal
Assignee:
Category:
haproxy
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Plus Target Version:
Affected Version:
Affected Plus Version:
Affected Architecture:

Description

Attempting to install either version of haproxy gives the following error on installation

>>> Installing pfSense-pkg-haproxy-devel... 
Updating pfSense-core repository catalogue...
pfSense-core repository is up to date.
Updating pfSense repository catalogue...
pfSense repository is up to date.
All repositories are up to date.
Checking integrity... done (0 conflicting)
The following 3 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
    haproxy: 2.6.6 [pfSense]
    lua53: 5.3.6 [pfSense]
    pfSense-pkg-haproxy-devel: 0.62_11 [pfSense]

Number of packages to be installed: 3

The process will require 5 MiB more space.
[1/3] Installing lua53-5.3.6...
[1/3] Extracting lua53-5.3.6: ......... done
[2/3] Installing haproxy-2.6.6...
[2/3] Extracting haproxy-2.6.6: ........ done
[3/3] Installing pfSense-pkg-haproxy-devel-0.62_11...
[3/3] Extracting pfSense-pkg-haproxy-devel-0.62_11: .......... done
Saving updated package information...
done.
Loading package configuration... done.
Configuring package components...
Loading package instructions...
Custom commands...
Executing custom_php_install_command()...
Fatal error: Uncaught Error: Non-static method haproxy_utils::haproxy_hostname_get_prefix() cannot be called statically in /usr/local/pkg/haproxy/haproxy.inc:1284
Stack trace:
#0 /usr/local/pkg/haproxy/haproxy.inc(2195): write_backend('/var/etc/haprox...', Resource id #77, 'mail_ipvANY', Array, Array)
#1 /usr/local/pkg/haproxy/haproxy.inc(2516): haproxy_writeconf('/var/etc/haprox...')
#2 /usr/local/pkg/haproxy/haproxy.inc(702): haproxy_check_run(1)
#3 /etc/inc/pkg-utils.inc(779) : eval()'d code(1): haproxy_custom_php_install_command()
#4 /etc/inc/pkg-utils.inc(779): eval()
#5 /etc/inc/pkg-utils.inc(897): eval_once('haproxy_custom_...')
#6 /etc/rc.packages(76): install_package_xml('haproxy-devel')
#7 {main}
  thrown in /usr/local/pkg/haproxy/haproxy.inc on line 1284
PHP ERROR: Type: 1, File: /usr/local/pkg/haproxy/haproxy.inc, Line: 1284, Message: Uncaught Error: Non-static method haproxy_utils::haproxy_hostname_get_prefix() cannot be called statically in /usr/local/pkg/haproxy/haproxy.inc:1284
Stack trace:
#0 /usr/local/pkg/haproxy/haproxy.inc(2195): write_backend('/var/etc/haprox...', Resource id #77, 'mail_ipvANY', Array, Array)
#1 /usr/local/pkg/haproxy/haproxy.inc(2516): haproxy_writeconf('/var/etc/haprox...')
#2 /usr/local/pkg/haproxy/haproxy.inc(702): haproxy_check_run(1)
#3 /etc/inc/pkg-utils.inc(779) : eval()'d code(1): haproxy_custom_php_install_command()
#4 /etc/inc/pkg-utils.inc(779): eval()
#5 /etc/inc/pkg-utils.inc(897): eval_once('haproxy_custom_...')
#6 /etc/rc.packages(76): install_package_xml('haproxy-devel')
#7 {main}
  thrownpkg-static: POST-INSTALL script failed
pkg-static: Fail to kill all processes:No such process
>>> Cleaning up cache... done.
Success

And when you try to start you get
PHP ERROR: Type: 1, File: /usr/local/pkg/haproxy/haproxy.inc, Line: 1284, Message: Uncaught Error: Non-static method haproxy_utils::haproxy_hostname_get_prefix() cannot be called statically in /usr/local/pkg/haproxy/haproxy.inc:1284
Stack trace:
#0 /usr/local/pkg/haproxy/haproxy.inc(2195): write_backend('/var/etc/haprox...', Resource id #54, 'mail_ipvANY', Array, Array)
#1 /usr/local/pkg/haproxy/haproxy.inc(2516): haproxy_writeconf('/var/etc/haprox...')
#2 /usr/local/pkg/haproxy/haproxy.inc(1349): haproxy_check_run(1)
#3 Standard input code(5): haproxy_configure()
#4 {main}
thrown @ 2022-10-13 16:10:00


Related issues

Is duplicate of Regression #13597: haproxy-devel PHP8 regression when saving a backend entryResolvedMarcos M

Actions
Actions #1

Updated by Robert Johnston 4 months ago

Robert Johnston wrote:

Attempting to install either version of haproxy gives the following error on installation
[...]
And when you try to start you get
[...]

Okay, having looked into this some more, I've got it at least running.

I edited `/usr/local/pkg/haproxy/haproxy.inc` and changed lines 1284, 1285 and 1298 to:

                        $serverprefix = (new haproxy_utils)->haproxy_hostname_get_prefix($be['address']);
                        $serveraddress = (new haproxy_utils)->haproxy_hostname_strip_prefix($be['address']);
                        if ($addrprefix && $serverprefix && $serverprefix !== $addrprefix) {
                                continue; // skip the server if its not 'usable' in this transparent-backend
                        }
                        if ($be['forwardto'] && $be['forwardto'] != "") {
                                $unix_socket = true;
                                $servers[] = "/{$be['forwardto']}.socket send-proxy-v2-ssl-cn";
                        } else {
                                if (in_array($serverprefix, array('unix@'))) {
                                        $servers[] = $serveraddress;
                                } elseif (is_ipaddr($serveraddress) || $use_haproxyresolvers) {
                                        $servers[] = $serveraddress;
                                } elseif (is_hostname($serveraddress)) {
                                        $dnsresult_servers = (new haproxy_utils)->query_dns($serveraddress, $dnsquerytype);

(The change is to replace `haproxy_utils::` with `(new haproxy_utils)->` which seems to work just fine)

Though digging a little deeper, the better fix would probably to be to set the functions in `haproxy_utils.inc` to static.

Actions #2

Updated by Danilo Zrenjanin 4 months ago

  • Status changed from New to Confirmed
  • Target version set to 2.7.0
  • Plus Target Version set to 23.01
  • Affected Version changed from 2.7.0 to 2.7.x

I was able to successfully install haproxy-devel 0.62_11.

2.7.0-DEVELOPMENT (amd64)
built on Fri Oct 14 06:04:12 UTC 2022
FreeBSD 14.0-CURRENT

But after creating a frontend a got PHP errors.

Crash report begins.  Anonymous machine information:

amd64
14.0-CURRENT
FreeBSD 14.0-CURRENT #0 devel-main-n255799-28f6f5e488e: Fri Oct 14 06:28:01 UTC 2022     root@freebsd:/var/jenkins/workspace/pfSense-CE-snapshots-master-main/obj/amd64/5sNqxS3O/var/jenkins/workspace/pfSense-CE-snapshots-master-main/sources/FreeBSD-src-dev

Crash report details:

PHP Errors:
[15-Oct-2022 09:52:22 Etc/UTC] PHP Fatal error:  Uncaught TypeError: Cannot access offset of type string on string in /usr/local/www/pkg.php:484
Stack trace:
#0 {main}
  thrown in /usr/local/www/pkg.php on line 484
[15-Oct-2022 12:45:26 Etc/UTC] PHP Fatal error:  Uncaught TypeError: Cannot access offset of type string on string in /etc/inc/util.inc:1912
Stack trace:
#0 /usr/local/pkg/haproxy/haproxy.inc(465): alias_get_type('80')
#1 /usr/local/pkg/haproxy/haproxy.inc(2751): haproxy_portoralias_to_list('80')
#2 /usr/local/pkg/haproxy/haproxy.inc(1829): get_frontend_bindips(Array)
#3 /usr/local/pkg/haproxy/haproxy.inc(1355): haproxy_writeconf('/var/etc/haprox...')
#4 /usr/local/www/haproxy/haproxy_listeners.php(97): haproxy_check_and_run(NULL, true)
#5 {main}
  thrown in /etc/inc/util.inc on line 1912
[15-Oct-2022 12:51:21 Etc/UTC] PHP Fatal error:  Uncaught TypeError: Cannot access offset of type string on string in /etc/inc/util.inc:1912
Stack trace:
#0 /usr/local/pkg/haproxy/haproxy.inc(465): alias_get_type('80')
#1 /usr/local/pkg/haproxy/haproxy.inc(2751): haproxy_portoralias_to_list('80')
#2 /usr/local/pkg/haproxy/haproxy.inc(1829): get_frontend_bindips(Array)
#3 /usr/local/pkg/haproxy/haproxy.inc(1355): haproxy_writeconf('/var/etc/haprox...')
#4 /usr/local/www/haproxy/haproxy_listeners.php(97): haproxy_check_and_run(NULL, true)
#5 {main}
  thrown in /etc/inc/util.inc on line 1912

No FreeBSD crash data found.
Actions #3

Updated by Danilo Zrenjanin 4 months ago

  • Target version deleted (2.7.0)
  • Plus Target Version deleted (23.01)
Actions #4

Updated by Jim Pingle 3 months ago

  • Subject changed from HAProxy PHP error on upgrade to PHP8.4 update to HAProxy PHP error on upgrade to PHP8.1 update
  • Parent task set to #13446
Actions #5

Updated by Robert Johnston 2 months ago

Okay, I have fixed all the errors I was getting. The procedure I used.

  1. Edit /usr/local/pkg/haproxy/haproxy_utils.inc so the last 4 function declarations in the class read:
            public static function is_valid_haproxy_hostname($hostname){
    ...
            public static function haproxy_hostname_strip_prefix($hostname){
    ...
            public static function haproxy_hostname_get_prefix($hostname){
    ...
            public static function query_dns($host, $querytype="A,AAAA") {
    

    (That is, insert "static" before "function")
  2. Use pkg create pfSense-pkg-haproxy-devel-0.62_11 to create a new version of the package.
  3. Use pkg remove pfSense-pkg-haproxy-devel-0.62_11 to remove the currently half-installed package.
  4. Use pkg add pfSense-pkg-haproxy-devel-0.62_11.pkg to install the just-created local package.

This allows the package to install successfully, the custom php routines to run to add haproxy to the interface, and everything to just work again. I'm pretty sure just updating the file in the package will fix (at least) this issue for everyone.

I also note this is in the haproxy-devel package.

Actions #6

Updated by Marcos M 2 months ago

  • Status changed from Confirmed to Duplicate
  • Assignee set to Marcos M
  • Plus Target Version set to 23.01
  • Affected Version deleted (2.7.x)
  • Affected Architecture deleted (amd64)

I'm marking this one as duplicate given that the fix for both packages has already been submitted and pending review. A patch is also available:
https://redmine.pfsense.org/issues/13597

Actions #7

Updated by Marcos M 2 months ago

  • Is duplicate of Regression #13597: haproxy-devel PHP8 regression when saving a backend entry added
Actions #8

Updated by Jim Pingle 2 months ago

  • Parent task deleted (#13446)
  • Plus Target Version deleted (23.01)
Actions

Also available in: Atom PDF