deuill / go-php

PHP bindings for the Go programming language (Golang)
MIT License
925 stars 105 forks source link

PHP 8.1.3 #72

Closed sailenicolas closed 2 years ago

sailenicolas commented 2 years ago

Hi, I'm trying to make it work in PHP8.1.3, but I find myself with a problem I can't really fix because I don't really understand Go. You can read the error here: https://gitlab.com/sailenicolas/gophp/-/jobs/2191492914

Apparently the problematic function is: receiver_define.
Basically this line: https://gitlab.com/sailenicolas/gophp/-/blob/php8/src/receiver.c#L236

The call to zend_register_internal_class causes a panic. If you don't mind, is there any way to make it work? I'm asking if you can point me in the right direction. The function calls are as follows: TestEngineDefine -> e.Define -> C.receiver_define -> zend_register_internal_class() and there it throws PANIC. I already checked other SAPI modules, php-src and PHP7 internals, I can't find the problem from the PHP8 side, so I think the problem is in the Go tests (I am only assuming).

The code is mostly the same...

Sorry for my english.

sailenicolas commented 2 years ago

The error is caused by this line: lowercase_name = zend_string_tolower_ex(orig_class_entry->name, EG(current_module)->type == MODULE_PERSISTENT);

The problem is EG(current_module)->type, there is a function called zend_string_tolower(), anyway, that's about it.

The line is in: do_register_internal_class() function which is called by zend_register_internal_class.

Anyway, if anyone want to check out the fork gitlab.com/sailenicolas/gophp

deuill commented 2 years ago

Thanks for taking a look here @sailenicolas, and for posting a link to your work here -- indeed go-php has not been tested with PHP 8.x, and though internal changes don't appear to be as dramatic as in the shift from PHP 5 to 7, things are bound to break. The library is mostly unmaintained, as I have no active use-case for it at the moment, but I welcome and will review any incoming PRs.

sailenicolas commented 2 years ago

Hi, thank you for you response. I completed updating it to make it compatible with PHP8.1. Although there is an issue without a cause. It doesn't happen on every test. See the Passing job and Failing job same commit.

This one: value_test.go:463: Value.Slice('map[c:2 t:1]'): expected '[]interface {}{1, 2}', actual '[]interface {}{2, 1}'

The next step is: make it work with goroutines.

Thank you.