Yoast / wordpress-seo

Yoast SEO for WordPress
https://yoast.com/wordpress/plugins/seo/
Other
1.77k stars 890 forks source link

Possible BuddyPress Yoast Conflict #4479

Closed espellcaste closed 7 years ago

espellcaste commented 8 years ago

I just wanted to share this error:

[28-Apr-2016 21:44:33 UTC] PHP Notice: bp_setup_current_user was called incorrectly. O usuário atual está sendo inicializado sem usar $wp>init().

Trace:

6 site\path\wp-content\plugins\wordpress-seo\admin\class-admin-init.php(68): get_current_user_id()

7 site\path\wp-content\plugins\wordpress-seo\admin\class-admin-init.php(60): WPSEO_Admin_Init->sync_about_version_from_cookie()

8 site\path\wp-content\plugins\wordpress-seo\wp-seo-main.php(301): WPSEO_Admin_Init->__construct()

9 [internal function]: wpseo_admin_init('')

10 site\path\wp-includes\plugin.php(525): call_user_func_array('wpseo_admin_ini...', Array)

11 site\path\wp-settings.php(277): do_action('plugins_loaded')

12 site\path\wp-config.php(166): require_once('C:\wamp\www\blo...')

13 site\path\wp-load.php(37): require_once('C:\wamp\www\blo...')

14 site\path\wp-admin\admin.php(31): require_once('C:\wamp\www\blo...')

15 site\path\wp-admin\index.php(10): re in site\path\wp-includes\functions.php on line 3897

espellcaste commented 8 years ago

The error was gone after I updated the plugin with the github version master version, although I had the most updated version from the recent updates.

Rarst commented 8 years ago

It is essentially their problem with handling early calls to related APIs, so they just stuff the warning in. See What is valid timing of using current_user_can() and related functions?.

I think we tuned this in most places, but we can't do anything about it if we need related information when we need it. I will take a look through the calls in trace some time.

mcguffin commented 8 years ago

PR #4518 might fix it for buddypress (and also bbPress, see #4517)

justingivens commented 8 years ago

I just changed the following lines and the errors when away.

WPSEO: 3.3.2 WP: 4.5.3 bbPress: 2.5.9 wp-seo-main.php line: 366 add_action( 'plugins_loaded', 'load_yoast_notifications' ); add_action( 'init', 'load_yoast_notifications' );

Here is the full error call stack: http://pasteboard.co/1SpYuGi1.png

vineettalwar commented 8 years ago

Same issue here Wordpress 4.5.3 BuddyPress 2.6.0 Yoast SEO 3.3.2
PHP Notice: bp_setup_current_user was called <strong>incorrectly</strong>. The current user is being initialized without using $wp->init().

Trace:
#6 site/wp-content/plugins/wordpress-seo/admin/class-yoast-notification-center.php(421): get_current_user_id()
#7 site/wp-content/plugins/wordpress-seo/admin/class-yoast-notification-center.php(31): Yoast_Notification_Center->retrieve_notifications_from_storage()
#8 site/wp-content/plugins/wordpress-seo/admin/class-yoast-notification-center.php(49): Yoast_Notification_Center->__construct()
#9 site/wp-content/plugins/wordpress-seo/wp-seo-main.php(383): Yoast_Notification_Center::get()
#10 [internal function]: load_yoast_notifications('')
#11 site/wp-includes/plugin.php(525): call_user_func_array('load_yoast_noti...', Array)
#12 /var/www/html/firemudfm.com/htdocs/wp-settings.php(277): do_action('plugins_loaded')
#13 /var/www/ht in site/wp-includes/functions.php on line 3897
sblomberg commented 8 years ago

According to BuddyPress ticket #6589 this should ideally be resolved here in the wordpress-seo plugin.

Can the load_yoast_notifications callback be registered on init instead of plugins_loaded in wp-seo-main.php:366 as mentioned by @imageinabox ?

billzhong commented 8 years ago

Same issue. It looks like the error move to "class-yoast-notification-center.php" file. Comment out line $stored_notifications = get_user_option( self::STORAGE_KEY, get_current_user_id() ); the error gone.

sblomberg commented 8 years ago

Still an issue as of:

Making my own changes to wp-seo-main.php was not sustainable, since it gets overwritten on nearly every Yoast SEO update. However, I was able to add my own fix and silence these Yoast SEO warnings by manually changing when the load_yoast_notifications and wpseo_admin_init are called within my own plugin like so:

add_action( 'plugins_loaded', 'load_wpseo_on_init_instead_of_plugins_loaded', 5 );

function load_wpseo_on_init_instead_of_plugins_loaded() {
    if ( is_admin() ) {
        remove_action( 'plugins_loaded', 'wpseo_admin_init', 15 );
        add_action( 'init', 'wpseo_admin_init', 15 );
    }

    remove_action( 'plugins_loaded', 'load_yoast_notifications' );
    add_action( 'init', 'load_yoast_notifications' );
}
Pcosta88 commented 8 years ago

Please inform the customer of conversation # 136452 when this conversation has been closed. User reports conflict between Yoast SEO and BuddyPress causing registration of new members on BP impossible According to user:

"The error occurs at this place: ... /wordpress-seo-premium/admin/class-yoast-notification-center.php:421

Here is the log, where the error occurs (… /bp-core-dependency.php:230):

function bp_setup_current_user() { $skip_warning = ( ( isset( $_REQUEST[‘wp_customize’] ) && ‘on’ === $_REQUEST[‘wp_customize’] ) || ( is_admin() && ‘customize.php’ === basename( $_SERVER[‘PHP_SELF’] ) ) );

if ( ! $skip_warning && ! did_action( ‘after_setup_theme’ ) ) { $e = new Exception; $trace = $e->getTraceAsString();

_doing_it_wrong( FUNCTION, __( ‘The current user is being initialized without using $wp->init().’, ‘buddypress’ ) . “\n===\nTrace:\n” . substr( $trace, strpos( $trace, ‘#6’ ) ) . “\n===\n”, ‘1.7’ ); }"

Tech Specs: Yoast SEO Premium 3.4 BuddyPress: 2.6.1.1 WordPress: 4.5.3

Pcosta88 commented 8 years ago

Please inform the customer of conversation # 136452 when this conversation has been closed.

sblomberg commented 7 years ago

We are no longer getting this PHP Notice as of:

Rarst commented 7 years ago

I think this is no longer present in latest bbs versions, confirmed with quick code search.