Project

General

Profile

Bug #8670

HAProxy PHP error

Added by Chris Macmahon about 1 year ago. Updated 11 months ago.

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

0%

Estimated time:
Affected Version:
2.4.4
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}

History

#1 Updated by Jim Pingle about 1 year ago

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

#2 Updated by Pi Ba about 1 year ago

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

#3 Updated by Chris Macmahon about 1 year ago

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

#4 Updated by Jim Thompson about 1 year ago

  • Assignee set to Steve Beaver
  • Target version set to 2.4.4

#5 Updated by King J about 1 year ago

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.

#6 Updated by Steve Beaver about 1 year ago

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

#7 Updated by Pi Ba about 1 year ago

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.. :)

#8 Updated by Chris Macmahon about 1 year ago

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}

#9 Updated by Luke Hamburg about 1 year ago

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

#10 Updated by Steve Beaver about 1 year ago

  • Status changed from New to This Sprint

#11 Updated by Steve Beaver about 1 year ago

  • Status changed from This Sprint to In Progress

#12 Updated by Steve Beaver about 1 year ago

  • Status changed from In Progress to Feedback

#13 Updated by Steve Beaver about 1 year ago

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?

#14 Updated by Pi Ba about 1 year ago

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..

#15 Updated by Jim Pingle about 1 year ago

  • 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.

#16 Updated by Pi Ba about 1 year ago

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 :)

#17 Updated by Steve Beaver about 1 year ago

  • Status changed from New to Assigned

#18 Updated by Pi Ba 12 months ago

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.

#19 Updated by Jim Pingle 11 months ago

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

#20 Updated by Chris Macmahon 11 months ago

I am no longer seeing these errors.

#21 Updated by Chris Macmahon 11 months ago

  • Status changed from Feedback to Resolved

Also available in: Atom PDF