Skip to content
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

Fatal error With WooCommerce #31942

Closed
2 tasks
cielartisan opened this issue Feb 20, 2022 · 19 comments · Fixed by #35339
Closed
2 tasks

Fatal error With WooCommerce #31942

cielartisan opened this issue Feb 20, 2022 · 19 comments · Fixed by #35339
Labels
plugin: woocommerce Issues related to the WooCommerce Core plugin. priority: normal The issue/PR is of normal priority—not many people are affected or there’s a workaround, etc. type: bug The issue is a confirmed bug.

Comments

@cielartisan
Copy link

Prerequisites (mark completed items with an [x]):

Issue Description:
My website is broken due to the WooCommerce extension
https://assolartisan.org/

There is only that on the website :
———
Fatal error: Uncaught Error: Call to undefined function putenv() in /var/www/legtux.org/users/cielartisan/www/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images-request.php:37 Stack trace: #0 /var/www/legtux.org/users/cielartisan/www/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images.php(49): WC_Regenerate_Images_Request->__construct() #1 /var/www/legtux.org/users/cielartisan/www/wp-includes/class-wp-hook.php(307): WC_Regenerate_Images::init() #2 /var/www/legtux.org/users/cielartisan/www/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #3 /var/www/legtux.org/users/cielartisan/www/wp-includes/plugin.php(474): WP_Hook->do_action() #4 /var/www/legtux.org/users/cielartisan/www/wp-settings.php(587): do_action() #5 /var/www/legtux.org/users/cielartisan/www/wp-config.php(95): require_once('...') #6 /var/www/legtux.org/users/cielartisan/www/wp-load.php(50): require_once('...') #7 /var/www/legtux.org/users/cielartisan/www/wp-admin/admin.php(34): require_once('...') #8 /var/www/legtux.org/users/cielartisan/www/wp-admin/index.php(10): require_once('...') #9 {main} thrown in /var/www/legtux.org/users/cielartisan/www/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images-request.php on line 37

Une erreur critique est survenue sur ce site. Veuillez consulter la boite de réception de l’e-mail d’administration de votre site pour plus d’informations.

En apprendre plus sur le débugage de WordPress. (->https://fr.wordpress.org/support/article/faq-troubleshooting/)
———

WHen I go to with recovery mode on the plingin page, there is this with the WooCommerce extension :
———
Une erreur de type E_ERROR a été causée dans la ligne 37 du fichier /var/www/legtux.org/users/cielartisan/www/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images-request.php. Message d’erreur : Uncaught Error: Call to undefined function putenv() in /var/www/legtux.org/users/cielartisan/www/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images-request.php:37 Stack trace: #0 /var/www/legtux.org/users/cielartisan/www/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images.php(49): WC_Regenerate_Images_Request->__construct() #1 /var/www/legtux.org/users/cielartisan/www/wp-includes/class-wp-hook.php(307): WC_Regenerate_Images::init() #2 /var/www/legtux.org/users/cielartisan/www/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #3 /var/www/legtux.org/users/cielartisan/www/wp-includes/plugin.php(474): WP_Hook->do_action() #4 /var/www/legtux.org/users/cielartisan/www/wp-settings.php(587): do_action() #5 /var/www/legtux.org/users/cielartisan/www/wp-config.php(95): require_once('...') #6 /var/www/legtux.org/users/cielartisan/www/wp-load.php(50): require_once('...') #7 /var/www/legtux.org/users/cielartisan/www/wp-admin/admin.php(34): require_once('...') #8 /var/www/legtux.org/users/cielartisan/www/wp-admin/plugins.php(10): require_once('...') #9 {main} thrown
———

I have inactivated the extension for the moment but it doesn't fix the problem with the extension...

@github-actions github-actions bot added the status: awaiting triage This is a newly created issue waiting for triage. label Feb 20, 2022
@jonathansadowski
Copy link
Contributor

Hi @cielartisan,

Thank you for submitting the issue. However, you didn’t fill out the details of the bug report template that we ask for. Without these details, we can’t fully evaluate this issue. Please provide us with the information requested so we could take a look further.

It sounds like you are unable to access the system status report because of the fatal error. It would be helpful if, instead of that, you could provide us any information about your version of PHP and the hosting environment.

Describe the bug
A clear and concise description of what the bug is. Please be as descriptive as possible; issues lacking detail, or for any other reason than to report a bug, may be closed without action.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Screenshots
If applicable, add screenshots to help explain your problem.

Expected behavior
A clear and concise description of what you expected to happen.

Isolating the problem (mark completed items with an [x]):

  • I have deactivated other plugins and confirmed this bug occurs when only WooCommerce plugin is active.
  • This bug happens with a default WordPress theme active, or Storefront.
  • I can reproduce this bug consistently using the steps above.

WordPress Environment

``` Copy and paste the system status report from **WooCommerce > System Status** in WordPress admin. ```

@jonathansadowski jonathansadowski added needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. and removed status: awaiting triage This is a newly created issue waiting for triage. labels Feb 21, 2022
@ObliviousHarmony ObliviousHarmony added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Feb 21, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2022

As a part of this repository’s maintenance, this issue is being marked as stale due to inactivity. Please feel free to comment on it in case we missed something.

After 7 days with no activity this issue will be automatically be closed.

@github-actions github-actions bot added the status: stale Issues that have no had any activity for some time. label Mar 1, 2022
@tonyuh
Copy link

tonyuh commented Mar 3, 2022

I'm having similar problem when moving from PHP7.4 to PHP8.0, this was a site moved to a new host with the same hosting (same VM spec) but newer version PHP installation.

Now I cannot access the website without disabling woocommerce.

image

I also get this message in my email:

`When seeking help with this issue, you may be asked for some of the following information:
WordPress version 5.8.3
Current theme: Customify (version 0.3.7) Current plugin: WooCommerce (version 6.1.0) PHP version 8.0.15

Error Details

An error of type E_ERROR was caused in line 37 of the file /www/wwwroot/web.scmpremier.com/wordpress/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images-request.php. Error message: Uncaught Error: Call to undefined function putenv() in /www/wwwroot/web.scmpremier.com/wordpress/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images-request.php:37
Stack trace:
#0 /www/wwwroot/web.scmpremier.com/wordpress/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images.php(49): WC_Regenerate_Images_Request->__construct()
#1 /www/wwwroot/web.scmpremier.com/wordpress/wp-includes/class-wp-hook.php(303): WC_Regenerate_Images::init()
#2 /www/wwwroot/web.scmpremier.com/wordpress/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters()
#3 /www/wwwroot/web.scmpremier.com/wordpress/wp-includes/plugin.php(470): WP_Hook->do_action()
#4 /www/wwwroot/web.scmpremier.com/wordpress/wp-settings.php(578): do_action()
#5 /www/wwwroot/web.scmpremier.com/wordpress/wp-config.php(99): require_once('...')
#6 /www/wwwroot/web.scmpremier.com/wordpress/wp-load.php(50): require_once('...')
#7 /www/wwwroot/web.scmpremier.com/wordpress/wp-login.php(12): require('...')
#8 {main}
thrown
`

So I followed the link to enter recovery mode and disable woocommerce plugin and exit recovery mode and my site is working again (without the shop).

@github-actions github-actions bot added needs: triage feedback Issues for which we requested feedback from the author and received it. and removed needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. status: stale Issues that have no had any activity for some time. labels Mar 3, 2022
@claudiosanches
Copy link
Contributor

Hello @tonyuh,

Could you provide more details?

Seems like PHP isn't making putenv() available, do you know if there's any module for security on your server that may be removing or disabling PHP functionality?
I haven't gone through this kind of situation yet, I'm not sure yet if it only happens to PHP 8, at least looking the PHP documentation seems that's still supported: https://www.php.net/manual/en/function.putenv.php

@claudiosanches claudiosanches added needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. and removed needs: triage feedback Issues for which we requested feedback from the author and received it. labels Mar 12, 2022
@tonyuh
Copy link

tonyuh commented Mar 12, 2022

Hi @claudiosanches

For the new installation of PHP 8.0 there are some blacklisted functions including putenv(). But what is weird is that the old installation with PHP 7.4 also has this function blacklisted, so I'm not sure why it worked before in PHP 7.4 but not PHP 8.0

@github-actions github-actions bot added needs: triage feedback Issues for which we requested feedback from the author and received it. and removed needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. labels Mar 12, 2022
@claudiosanches claudiosanches added needs: developer feedback Issues that need feedback from one of the WooCommerce Core developers. and removed needs: triage feedback Issues for which we requested feedback from the author and received it. labels Mar 14, 2022
@woocommercebot
Copy link
Collaborator

Hi @cielartisan,

Thank you for opening the issue! It requires further feedback from the WooCommerce Core team.

We are adding the needs developer feedback label to this issue so that the Core team could take a look.

Please note it may take a few days for them to get to this issue. Thank you for your patience.

@barryhughes
Copy link
Member

It sounds like this function is being deliberately disabled via the disable_functions directive. A workaround, assuming a fairly standard WordPress setup, would be to create a new file at:

wp-content/mu-plugins/putenv.php

Containing:

<?php

if ( ! function_exists( 'putenv' ) ) {
	/**
	 * No-op placeholder for cases where putenv() is disabled via an .ini file.
	 *
	 * @param string $assignment
	 */
	function putenv( string $assignment ) {}
}

This might just help you to workaround this issue, however the very best course of action would be to make a correction to your PHP config (working with your web host if necessary to achieve this).

The code that calls putenv() has been in place for over 4 years and this seems to be the first time the problem has arisen (though, search functionality over on the wordpress.org is not working at time of writing—too many requests), so I may be missing something, but my inclination is that it would still be best to work things out per the above notes: this is a standard PHP function, not something that is coming from an optional extension, so it's reasonable for us to expect it to be available.

@AlkoKod
Copy link

AlkoKod commented Jun 17, 2022

<?php

if ( ! function_exists( 'putenv' ) ) {
	/**
	 * No-op placeholder for cases where putenv() is disabled via an .ini file.
	 *
	 * @param string $assignment
	 */
	function putenv( string $assignment ) {}
}

Thank you so much!!

@barryhughes
Copy link
Member

Welcome!

@jeklau
Copy link

jeklau commented Jul 27, 2022

I also encountered this problem, after a Google search problem, I had to remove 'putenv' from the php8 or 8.1 function blacklist, and the site was restored.

@masteradhoc
Copy link
Contributor

+1 had the same issue and fixed it over the workaround.
Though had then some issues with WooCommerce Blocks why i reverted to php 7.4 for now.

Hoster seems to have deactivated putenv()

@nkls-so
Copy link
Contributor

nkls-so commented Oct 10, 2022

This is the reason why it worked before PHP 8, putenv() is implemented in WooCommerce as follows:

// This is needed to prevent timeouts due to threading. See https://core.trac.wordpress.org/ticket/36534.
@putenv( 'MAGICK_THREAD_LIMIT=1' ); // @codingStandardsIgnoreLine.

Prior to PHP 8.0.0, it was possible for the @ operator to disable critical errors that will terminate script execution. For example, prepending @ to a call of a function which did not exist, by being unavailable or mistyped, would cause the script to terminate with no indication as to why.

https://www.php.net/manual/en/language.operators.errorcontrol.php

@barryhughes
Copy link
Member

That's a good observation; re-opening as, in that case, probably we should test for the existence of the function/use our own wrapper function).

@barryhughes barryhughes reopened this Oct 10, 2022
@barryhughes barryhughes removed the needs: developer feedback Issues that need feedback from one of the WooCommerce Core developers. label Oct 10, 2022
@barryhughes barryhughes added type: bug The issue is a confirmed bug. priority: normal The issue/PR is of normal priority—not many people are affected or there’s a workaround, etc. labels Oct 10, 2022
nkls-so added a commit to nkls-so/woocommerce that referenced this issue Oct 26, 2022
@beaulebens beaulebens mentioned this issue Dec 7, 2022
7 tasks
@xue28
Copy link

xue28 commented Dec 16, 2022

barryhughes pushed a commit that referenced this issue Dec 16, 2022
… issues with OpenMP (#35339)

* Use Imagick to set threads instead of putenv() (#31942)

* Adapt code to the coding styles

* Changelog and PHPCS fix.

Co-authored-by: Vedanshu Jain <vedanshu.jain.2012@gmail.com>
@henryliangt
Copy link

I had the same trouble.

I resolved it by white list the putenv() function.
then it all worked.

give a try

@edison2rinen
Copy link

I still have the same trouble, i am using a shared hosting. I am going back and forth with the server admin about need to 1) enable the putenv() function on the server or alternatively, 2) remove this function from the blacklist on php.ini.

I thought this has been resolved via #35339 but I am encountering this right now.

@barryhughes
Copy link
Member

Hi @edison2rinen,

I thought this has been resolved via #35339

So did we :-)

  1. Are you certain the problem is coming from WooCommerce and not another plugin?
  2. What version of WooCommerce are you using?
  3. Can you share the full error message and stack trace (if you have one)?

@edison2rinen
Copy link

Hi @edison2rinen,

I thought this has been resolved via #35339

So did we :-)

  1. Are you certain the problem is coming from WooCommerce and not another plugin?
  2. What version of WooCommerce are you using?
  3. Can you share the full error message and stack trace (if you have one)?

Hi @barryhughes,

I figured it out eventually. I had to remove plugins (that i no longer use and were deactivated). I didn't know deactivated plugins can cause this issue. Thanks for replying, I appreciate it!

@barryhughes
Copy link
Member

I'm a little surprised, too, but glad you found a solution. Fwiw, based on your feedback I did scan the (WooCommmerce Core) codebase for further uses of putenv we might have missed, but did not find any (at least, not outside of the test suite).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: woocommerce Issues related to the WooCommerce Core plugin. priority: normal The issue/PR is of normal priority—not many people are affected or there’s a workaround, etc. type: bug The issue is a confirmed bug.
Projects
None yet
15 participants