Home › Forums › WoodMart support forum › PHP notices header already sent
PHP notices header already sent
- This topic has 14 replies, 2 voices, and was last updated 5 years, 2 months ago by metuza.
-
AuthorPosts
-
October 1, 2019 at 2:43 pm #147880
metuzaParticipantI have 3 sites, 1 running on 4.1.0 and second on v4.0.4 and both gives me this notice in debug log:
[01-Oct-2019 14:40:02 UTC] PHP Notice: wp_woocommerce_session_baea78ae712607fb6687853a2c9c06b2 cookie cannot be set – headers already sent by /wp-content/plugins/wordpress-seo/inc/class-wpseo-utils.php on line 1194 in /wp-content/plugins/woocommerce/includes/wc-core-functions.php on line 887
[01-Oct-2019 14:40:11 UTC] PHP Notice: wp_woocommerce_session_baea78ae712607fb6687853a2c9c06b2 cookie cannot be set – headers already sent by /wp-includes/general-template.php on line 3137 in /wp-content/plugins/woocommerce/includes/wc-core-functions.php on line 887My third site on v3.8.2 does not have these notices. All sites has mostly the same setup and plugins. And i did a test on my v4.0.4 site, reverted back to 3.8.2 and all issues/notices dissapeared. So it seems like there is an conflict with later versions.
Any idea?
Brgds
RuneOctober 1, 2019 at 7:53 pm #147928
metuzaParticipantI have now narrowed down the issue and after deactivating ALL plugins and tested 3 different theme versions (woodmart) i still get the notices but now they look like this:
[01-Oct-2019 16:51:55 UTC] PHP Notice: wp_woocommerce_session_59f9adf68b3deeb3d144141c2fae7308 cookie cannot be set – headers already sent by /wp-includes/class.wp-scripts.php on line 209 in /wp-content/plugins/woocommerce/includes/wc-core-functions.php on line 887
The above notice appear in v4.0.4 and 4.1.0 but not in v3.8.2 or any standard themes.
Brgds
RuneOctober 2, 2019 at 6:24 am #147962
Artem TemosKeymasterHi,
These notices appear in the WooCommerce plugin when we use their cookies mechanisms for our wishlist and compare. We really don’t know in which exactly situations they appear and how to avoid them. But they are absolutely harmless and you can ignore them.
Kind Regards
October 2, 2019 at 8:31 am #147991
metuzaParticipantOki, its just annoying when using debug-log actively as it fills up with thousands of lines in a few days.
I have found that they appear only in archive pages and they appear even if i have deactivated wishlist, compare, header banner and promo popup.
October 2, 2019 at 9:52 am #148011
Artem TemosKeymasterDo you have WP_DEBUG mode enabled in the file
wp-config.php
? Try to turn it off.October 2, 2019 at 9:58 am #148012
metuzaParticipantYes i have it enabled because i am using it actively when building websites. If i turn it of i will not be able to follow up on any issues during my development.
Rune
October 2, 2019 at 11:19 am #148027
Artem TemosKeymasterYes, but on live website, this option should be turned on. You need to do your development on a staging environment.
October 2, 2019 at 1:08 pm #148058
metuzaParticipantDevelopment and testing is always done in my staging sites but sometimes, like yesterday, i had to debug a payment gateway issue which only appeared for some users on specific browsers then i had to enable it in my live site a few hours. But log was difficult to read as the record i was looking for was in between 2-3000 lines of this cookie notices. It adds up extremely fast in my live site because it has high traffic.
It is just annoying nothing else 😉
Rune
October 2, 2019 at 1:23 pm #148063
Artem TemosKeymasterWe will try to fix these notices but currently, we don’t have a solution to this, unfortunately.
October 2, 2019 at 2:13 pm #148084
metuzaParticipantI just did a test in /wp-content/themes/woodmart/inc/integrations/woocommerce/functions.php
I commented out the add_action as below and issue dissapeared. isn it a little late to set session cookie “woodmart_before_shop_page” as other html has already been output?
if( ! function_exists( 'woodmart_set_customer_session' ) ) { //add_action( 'woodmart_before_shop_page', 'woodmart_set_customer_session', 10 ); function woodmart_set_customer_session() { if( ! function_exists( 'WC' ) ) return; if ( WC()->version > '2.1' && ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' ) ) : WC()->session->set_customer_session_cookie( true ); endif; } }
October 2, 2019 at 2:51 pm #148102
metuzaParticipantChanged the above mentioned action:
add_action( 'woodmart_before_shop_page', 'woodmart_set_customer_session', 10 ); to add_action( 'woocommerce_init', 'woodmart_set_customer_session' );
and everything seems to work just fine, no php notices, and user session is set and ok.
October 2, 2019 at 11:49 pm #148100
Artem TemosKeymasterThere is some problem with this code if we use another hook for that. It has to be there to work smoothly.
October 3, 2019 at 9:04 am #148211
metuzaParticipantCan you say anything about what kind of problems? I have now tested my site using the other hook for the last 12 hours and have to say that my site never has been working so smooth before.
I have for a few months had some wierd problems with a payment gateway not registering address info correctly so orders has been cancelled. This is used as a quick-pay where user does not enter any information as everything is stored in their smartphone, but the reporting back to orders has been messed up. This is now working perfectly fine.
Also had some wierd redirects when clicking the category links in header titles, always showing the icon-roller first the opened the page which i actually left before it opens the new page. This is now working perfectly fine.
Now tested login/logout, wishlist, compare, promo banners, promo popup, header banner + + + and everything seems to work perfectly fine so it would be interessting to test for the issues you know about.
Brgds
RuneOctober 3, 2019 at 12:53 pm #148265
metuzaParticipantSorry, forgot to mention that also this line:
if( ! function_exists( 'WC' ) ) return;
Needs to be changed to this:
if( ! is_shop() || ! function_exists( 'WC' ) ) return;
To avoid possible unconditional fatal errors.
Brgds
RuneOctober 3, 2019 at 10:36 pm #148239
Artem TemosKeymasterOK, you can keep the fix in your child theme and check how it works.
-
AuthorPosts
- You must be logged in to create new topics. Login / Register