Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.59k stars 799 forks source link

Stats: PHP Warning in Stats dashboard widget #5792

Closed jeherve closed 7 years ago

jeherve commented 7 years ago

Steps to reproduce the issue

  1. Start from a site running WordPress 4.7 and Jetpack 4.4.2 Beta.
  2. Enable Stats.
  3. Disable WP_DEBUG
  4. Go to the main dashboard.
  5. When the stats widget loads and Jetpack posts to wp-admin/admin.php?page=stats&noheader&chart=flot-stats-data, the stats data is returned, but 2 errors are also returned at the end of the response:
<br />
<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at /wp-includes/functions.php:3673) in <b>/wp-includes/rest-api.php</b> on line <b>480</b><br />
<br />
<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at /wp-includes/functions.php:3673) in <b>/wp-includes/rest-api.php</b> on line <b>480</b><br />
jeherve commented 7 years ago

When turning WP_DEBUG on, I can't pinpoint any error that would give me more details about this.

dereksmart commented 7 years ago

Hm I'm not seeing it. Do you by any chance have any functionality plugins that may be echoing out things early like init (maybe for debugging purposes?)

jeherve commented 7 years ago

I can't see anything that jumps out at me after a quick look. Anything else I could do to debug this?

dereksmart commented 7 years ago

interesting that the line it's pointing to references a deprecated function https://github.com/WordPress/WordPress/blob/863505cf81ad01d56a67aa9710fd597367a22771/wp-includes/rest-api.php#L480

eliorivero commented 7 years ago

Can't reproduce this issue on master.

jeherve commented 7 years ago

Still there for me unfortunately, but the problem is limited to one site so I think it's best to close this. I'll reopen when I can reproduce on another site.

madhattermattic commented 7 years ago

I appear to have the same issue:

1422793-t

Jetpack won't connect and at the top of the Jetpack settings screen is this:

Warning: Cannot modify header information - headers already sent by (output started at /home/.../wp-admin/includes/template.php:1995) in /home/.../wp-includes/rest-api.php on line 480

Here is the plugin list:

Akismet, Imsanity, Jetpack (4.4.2), Mashshare - Sharebar Add-On, Mashshare Share Buttons, Menu Icons, Related Posts by Sovrn, tagDiv Social Counter, tagDiv Speed Booster, Tweetily, WPBakery Visual Composer, and Yoast SEO (4.0.2)

WordPress is up-to-date. Any ideas would be fantastic!

pmciano commented 7 years ago

Also reported here 3005150-t

Warning

Site running Jetpack 4.5 and WordPress 4.7.1

Plugins:

            [0] => ad-injection/ad-injection.php
            [1] => ad-inserter/ad-inserter.php
            [2] => adsoptimal/adsoptimal.php
            [3] => advanced-ads/advanced-ads.php
            [4] => affiliate-link-cloaking/affiliatelinkcloaking.php
            [5] => akismet/akismet.php
            [6] => bbpress-login-register-links-on-forum-topic-pages/bbpress-login-register-links-on-forum-page.php
            [7] => bbpress-wp-tweaks/bbpress-wp-tweaks.php
            [8] => bbpress/bbpress.php
            [9] => buddypress/bp-loader.php
            [10] => contextual-related-posts/contextual-related-posts.php
            [11] => corner-ad/corner-ad.php
            [12] => custom-fields-as-meta-tags/custom_fields_as_meta_plugin.php
            [13] => easy-site-importer/easy-site-importer.php
            [14] => eps-301-redirects/eps-301-redirects.php
            [15] => gd-bbpress-tools/gd-bbpress-tools.php
            [16] => google-analytics-dashboard-for-wp/gadwp.php
            [17] => head-footer-code/head-footer-code.php
            [18] => hellobar/hellobar.php
            [19] => jetpack-mobile-theme-ads/jp-minileven-ads.php
            [20] => jetpack/jetpack.php
            [21] => no-self-ping/no-self-pings.php
            [22] => page-links-to/page-links-to.php
            [23] => pc-google-analytics/pc-google-analytics.php
            [24] => popup-builder/popup-builder.php
            [25] => popup/popup.php
            [26] => redirection/redirection.php
            [27] => tablepress/tablepress.php
            [28] => ultimate-swf-flash-display-widget/ultimate-swf-flash-display-widget.php
            [29] => widget-clone/nine3-clone-widgets.php
            [30] => widget-importer-exporter/widget-importer-exporter.php
            [31] => wordpress-seo/wp-seo.php
            [32] => wp-auto-spinner/wp-auto-spinner.php
            [33] => wp-external-links/wp-external-links.php
            [34] => wp-insert-code/index.php
            [35] => wp-power-stats/wp-power-stats.php
            [36] => wp-scraper/wp-scraper.php
            [37] => wp-smushit/wp-smush.php
            [38] => wp-statistics/wp-statistics.php
            [39] => wp-super-cache/wp-cache.php
            [40] => wp-web-scrapper/wpws.php
lschuyler commented 7 years ago

Reported in 3009851-t

Warning: Cannot modify header information - headers already sent by (output started at /home/public_html/wp-admin/includes/template.php:1995) in /home/public_html/wp-includes/rest-api.php on line 480

Twenty Fifteen theme, JP 4.5, only in Jetpack area of dashboard.

lschuyler commented 7 years ago

Also reported in 3023757-t Same error as above, but line 488 Many plugins, asking them to try with them deactivated.

chaselivingston commented 7 years ago

Also reported in 3026769-t

PaulXLE commented 7 years ago

Hi Newbie alert... I'm new to Github, WP, Jetpack... I am the 3026769 report above... and as I'm new to all this and am just playing with WP, I have just two plugins, so it was easy for me to test this... and yes, it turns out that if I deactivate "WP-FileManager" everything Jetpack then works - I re-activate, it doesn't work - so there you have it (well one explanation anyway). Thanks for your reply Chase Paul

lschuyler commented 7 years ago

Reported in 3005034-t too

Warning: Cannot modify header information - headers already sent by (output
started at /home/content/a2pnexwpnas01_data02/81/3323681/html/wp-admin/includes/template.php:1995)
in /home/content/a2pnexwpnas01_data02/81/3323681/html/wp-includes/rest-api.php
on line 501

GoDaddy managed WP hosting

jeherve commented 7 years ago

Also reported here: https://wordpress.org/support/topic/warning-cannot-modify-header-information-headers-already-sent-by-75/

jeherve commented 7 years ago

Quick follow-up on this: in my tests so far the conflicts always seemed caused by deprecated functions in plugins or the active theme, appearing in the Jetpack dashboard because of our use of the WordPress REST API.

If you run into the same problem and are willing to run more tests, you could try the following:

  1. Install and activate the Query Monitor plugin.
  2. Load the dashboard page and check that the error is still displayed.
  3. In Query Monitor, locate the `wp-includes/rest-api.php` call where the error appears.
  4. In the "Call Stack" section, check the different calls that are run. Below each call you should see the file making that call in grey.
  5. If one of the calls is made by another plugin or your theme, try deactivating that plugin or switching themes.
  6. If that solves the problem, you can send that call stack to the plugin or theme author to let them know.

I hope this helps!

lschuyler commented 7 years ago

Following up with the users I mentioned above. Two plugins with deprecated functions has been the cause so far. Thanks @jeherve!