php icon indicating copy to clipboard operation
php copied to clipboard

Kirby support: possible conflict with Kirby go() function and swoole extension go() function.

Open dadambickford opened this issue 4 years ago • 7 comments

Bug report

  • Version: [email protected]
  • URL: https://kirby-test.vercel.app/
  • Repository: https://github.com/dadambickford/kirby_test

Description

The PHP error is

Fatal error: Cannot redeclare go() in /var/task/user/kirby/config/helpers.php on line 222

We can not figure out the source of the original go() function that kirby is conflicting with. We've discovered many different forms of using PHP reflection to try and find the source with no luck - https://stackoverflow.com/questions/7026690/reconstruct-get-code-of-php-function - and posting our own question - https://stackoverflow.com/questions/64867808/get-function-definition-in-string-form-in-php

The only hint that we found is that the PHP extension swoole has a go() function that sounds like it may be the conflict (https://github.com/getkirby-v2/kirby/issues/643) however all of our attempts to disable that extension have failed, like overriding the php.ini config. Is there a way to not include that with vercel-php? maybe a past version that doesn't have it? or any other ideas?

Thanks in advance.

dadambickford avatar Nov 19 '20 20:11 dadambickford

Hi @dadambickford. Thank you for issue. That's really strange error, but I got it you need to disable some php extension. I think there is now way how to disable already enabled extension, right? I need to think about it and introduce some logic to build phase, how to comment-out particular extension.

Something like:

{
  "build": {
    "env" : {
      "VERCEL_PHP_DISABLE_EXTENSIONS": "swoole", 
      # maybe in conjunction
      "VERCEL_PHP_ENABLE_EXTENSIONS": "json curl ..."
    }
  }
}

f3l1x avatar Nov 19 '20 21:11 f3l1x

I'm admittedly very amateur when it comes to PHP, so I can't say for sure. We did read about a PHP_MODULES_DISABLE environment variable but passing that with the swoole value did not do what we hoped. The php.ini override we attempted was just setting extensions to an empty string, but yeah that didn't disable it.

I think a config option would be a clean solution, and if we eventually get this sorted out I'd love to submit a working Kirby boilerplate to the examples repo.

dadambickford avatar Nov 19 '20 22:11 dadambickford

Hi there @f3l1x, wanted to touch base on this again and see if you've had any time to think about it.

dadambickford avatar Dec 22 '20 19:12 dadambickford

Hi @dadambickford. Unfortunately no, I tried to enjoy Christmas time. :-) I've released new v0.4.0 with PHP 8.0. Could you please test it? If so, this will be my next issue.

f3l1x avatar Jan 02 '21 16:01 f3l1x

No worries! Hope you had a good holiday. I will give that a test and let you know.

dadambickford avatar Jan 21 '21 06:01 dadambickford

Add swoole.use_shortname=Off to your php.ini file. It will make Swoole skip the go() function creation.

leocavalcante avatar Feb 17 '22 17:02 leocavalcante

@leocavalcante It works for me. Can you confirm it @dadambickford ?

f3l1x avatar Apr 09 '22 18:04 f3l1x