New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Call to undefined function Carbon_Fields\Provider\add_filter() with Bedrock / PHPUnit #899
Comments
I'm seeing the same issue with carbon-field-number when running phpunit. It seems to stem from field.php file being autoloaded which automatically runs some code as part of extend() that tries to use add_filter() whether or not WordPress is actually loaded at the time. I'm not sure what the proper fix would be but in the meantime I just added a test to check in the register() method of core/Provider/Container_Condition_Provider.php:
|
Are there any changes on this issue? |
Experiencing the same issue when running phpunit after installing it through composer.
|
Hi @piggydoughnut , Are you using Bedrock ? |
Hey @dimitriBouteille! Ah, actually not. I missed that in your question. I just did a simple setup using composer https://phpunit.de/ |
Hello Dimitri, I had the same error while trying to create a new custom field into a plugin (i.e. into a theme). I think that Bedrock try to load the custom field before WordPress is loaded, that's the reason why you get this error. I handled it by removing the autoload of my custom field anywhere, then I generated the autoload with Please, note that, this a temporary solution, you have to fix the autoload before sending it to a production environment. |
Hi @piggydoughnut and @mihdan @hafrang found a solution to fix the bug. Careful, as Hafrand says, this is a temporary solution. Do not hesitate to test this fix and make a return :) |
@dimitriBouteille I don't think this should be closed, it isn't resolved yet, it is only a hack |
Hello @peterkracik , I’m reopening the issue but I’m not sure he has a new answer :( Do not hesitate to propose a solution to fix this problem :) |
@jorostoyanov Do you have any idea how to fix this problem? |
Version
Expected Behavior
I just installed the carbon-field-icon package (https://packagist.org/packages/htmlburger/carbon-field-icon) and I have the following error:
I tried to create a custom field, but I have the same problem ...
I’m using Bedrock for the setup.
My composer.json
Fix
#899 (comment) Careful, this is a temporary solution.
https://discourse.roots.io/t/global-autoload/18863/2
The text was updated successfully, but these errors were encountered: