Project

General

Profile

Actions

Bug #8670

closed
CM

HAProxy PHP error

Bug #8670: HAProxy PHP error

Added by Chris Macmahon about 8 years ago. Updated almost 8 years ago.

Status:
Resolved
Priority:
Normal-package
Assignee:
-
Category:
haproxy
Target version:
Start date:
07/20/2018
Due date:
% Done:

0%

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

Description

On update to snapshot 2.4.4.a.20180718.2256:

HA Proxy errors with PHP:
PHP ERROR: Type: 1, File: /usr/local/pkg/haproxy/haproxy.inc, Line: 2722, Message: Uncaught Error: Cannot create references to/from string offsets in /usr/local/pkg/haproxy/haproxy.inc:2722
Stack trace:
#0 /usr/local/pkg/haproxy/haproxy.inc(910): get_backend_acls(Array, 'http')
#1 /usr/local/pkg/haproxy/haproxy.inc(1944): write_backend('/var/etc/haprox...', Resource id #51, 'observium_http_...', Array, Array)
#2 /usr/local/pkg/haproxy/haproxy.inc(2223): haproxy_writeconf('/var/etc/haprox...')
#3 /usr/local/pkg/haproxy/haproxy.inc(1173): haproxy_check_run(1)
#4 Standard input code(5): haproxy_configure()
#5 {main}

JP Updated by Jim Pingle about 8 years ago Actions #1

  • Subject changed from HA Proxy to HAProxy PHP error
  • Category set to haproxy
  • Affected Version set to 2.4.4
  • Affected Architecture All added
  • Affected Architecture deleted ()

PB Updated by Pi Ba about 8 years ago Actions #2

I suspect your using 'haproxy' package? Can you verify that haproxy-devel is working properly?

CM Updated by Chris Macmahon about 8 years ago Actions #3

Yup, using Haproxy-Dev works. This is for PHP migration.

JT Updated by Jim Thompson about 8 years ago Actions #4

  • Assignee set to Anonymous
  • Target version set to 2.4.4

KJ Updated by King J about 8 years ago Actions #5

I have also run in to this on 2.4.4.a.20180723.1255 and HAProxy 0.57_5. Upgrading to HAProxy-devel (0.59_1) as suggested above has also resolved the issue for me.

Updated by Anonymous about 8 years ago Actions #6

This particular error has been fixed. It may, however, reveal more :(

PB Updated by Pi Ba about 8 years ago Actions #7

If haproxy-devel package is working properly, then i should probably copy its components/fixes/features over to haproxy package.
Most if not all cases of php7 issues have been fixed in the -devel version (afaik). And if no bugs have been added it should be safe to copy the gui components over the stable version. I just always wonder if stuff really works properly, and tend to just include more changes into -devel when i start looking, and then again feel uncomfortable if it is the right moment to copy it over the stable package.. Anyhow no point in fixing the 'stable' version at this moment imho..

Ill send a PR, i guess we will find out.. :)

CM Updated by Chris Macmahon about 8 years ago Actions #8

Found another:
PHP ERROR: Type: 1, File: /usr/local/pkg/haproxy/haproxy.inc, Line: 2859, Message: Uncaught Error: Cannot use string offset as an array in /usr/local/pkg/haproxy/haproxy.inc:2859
Stack trace:
#0 /usr/local/www/haproxy/haproxy_listeners.php(329): get_frontend_acls('A')
#1 {main}

→L Updated by → luckman212 about 8 years ago Actions #9

Is this bug possibly causing this error as well?
https://www.reddit.com/r/PFSENSE/comments/92it0e/haproxy_setup_issue/e361t9q/

TL;DR - Under ACLs, "Server Name Indication TLS extension matches:" option does not appear for newly created FrontEnds

Updated by Anonymous about 8 years ago Actions #10

  • Status changed from New to 13

Updated by Anonymous about 8 years ago Actions #11

  • Status changed from 13 to In Progress

Updated by Anonymous about 8 years ago Actions #12

  • Status changed from In Progress to Feedback

Updated by Anonymous about 8 years ago Actions #13

It is not clear what this Redmine issue now means. It seems to have morphed into other errors (which may , or may not still exist) and it has blurred the lines between haproxy and haproxy-devel

Can we clarify this ticket, or close it and make a new one please?

PB Updated by Pi Ba about 8 years ago Actions #14

The ACL issue from #9 was actually a 'user mistake', that was cleared on the forum.

This redmine ticket is i.m.o. about arrays and php7 on 2.4.4 being more strict than php5 with their usage.

It 'should' mostly work now, but i have still got some pending commits regarding the way of handling this..

JP Updated by Jim Pingle about 8 years ago Actions #15

  • Status changed from Feedback to New

Yes, this is still about PHP7 array issues, and there are a few outstanding. Here is one that happens with a clean install of haproxy on a firewall that has never had haproxy before:

8:58:35 PHP ERROR: Type: 1, File: /usr/local/pkg/haproxy/haproxy.inc, Line: 2189, Message: Uncaught Error: Cannot create references to/from string offsets in /usr/local/pkg/haproxy/haproxy.inc:2189
Stack trace:
#0 /usr/local/pkg/haproxy/haproxy.inc(2226): haproxy_get_transparent_backends()
#1 /etc/inc/filter.inc(4375): haproxy_generate_rules('filter')
#2 /etc/inc/filter.inc(410): discover_pkg_rules('filter')
#3 /etc/rc.filter_configure_sync(29): filter_configure_sync()
#4 {main}
  thrown

Have a look at the new function I just added in https://github.com/pfsense/pfsense/commit/65b5efa73bb866f0642de640174fb7028a4fc604 -- it will create nested arrays for you only if they are not currently arrays. So it leaves existing settings alone but will make sure they exist before you use them.

For example that line in haproxy.inc is:

$a_backends = &$config['installedpackages']['haproxy']['ha_pools']['item'];

With that function, you can do this:

init_config_arr(array('installedpackages', 'haproxy', 'ha_pools', 'item'));
$a_backends = &$config['installedpackages']['haproxy']['ha_pools']['item'];

It is only in 2.4.4 at the moment, so if you want to keep the same code on other branches you could either copy it with a function_exists() check or a version check before running it. That's a lot better than four levels of manual is_array() if/create array/blah sections.

PB Updated by Pi Ba about 8 years ago Actions #16

I'm going to revisit all those items.. and get rid of this kind of array lookup completely replacing them with this single function call:
$a_backends = &getarraybyref($config,'installedpackages','haproxy','ha_pools','item');

My initial though of a central 'initialize' function preferably once on installation can not guarantee that stuff is and stays initialized. And to avoid cluttering the code with lots of !is_array(x) { x = array() } lines.. this is i guess the better option..

First i want be sure that 2.4.3 works properly though.. Next PR should probably not get backported immediately :)

Updated by Anonymous about 8 years ago Actions #17

  • Status changed from New to Assigned

PB Updated by Pi Ba about 8 years ago Actions #18

This issues with haproxy should be fixed with current 0.59_11 version. If not please let me know the exact error you get and when that happens.

JP Updated by Jim Pingle about 8 years ago Actions #19

  • Status changed from Assigned to Feedback
  • Priority changed from Normal to Normal-package

CM Updated by Chris Macmahon almost 8 years ago Actions #20

I am no longer seeing these errors.

CM Updated by Chris Macmahon almost 8 years ago Actions #21

  • Status changed from Feedback to Resolved
Actions

Also available in: Atom