WPSEO 1.5.2.2: Conflict with Log Deprecated Notices plugin? #881

Closed
satrya opened this Issue Mar 20, 2014 · 10 comments

3 participants

@satrya

I don't know the issue is from WPSEO or not, but I just updated WPSEO on my local host then some notice appear.

Notice: Undefined index: file in ...\wp-content\plugins\log-deprecated-notices\log-deprecated-notices.php on line 244
Notice: Undefined index: line in ...\wp-content\plugins\log-deprecated-notices\log-deprecated-notices.php on line 245

When I deactivated WPSEO, the notice disappear.

@barrykooij

The error is caused by the 'log-deprecated-notices' plugin. It's strange though that WPSEO is causing these errors to display.

@jrfnl any clue what might be causing this?

@jrfnl

@satrya Would you mind doing a backtrace as explained here to help me figure out which deprecated function/method is causing the notices ? Thanks.

@jrfnl jrfnl added a commit to jrfnl/wordpress-seo that referenced this issue Mar 20, 2014
@jrfnl jrfnl Quite probably fix issue #881 867a988
@jrfnl

@satrya The backtrace would still be appreciated to be sure, but in the mean time I've done some checking and I believe I've found the cause. I've send in a fix in PR #887. Closing the issue in favour of the PR.

@jrfnl jrfnl closed this Mar 20, 2014
@satrya

@jrfnl I tried to manually updated the code from https://github.com/Yoast/wordpress-seo/pull/887/files but the notice still appear. Then I copy paste https://gist.github.com/jrfnl/5925642 to my wp-config.php I dont see any error in the error.log

@jrfnl

@satrya Thanks for checking. The notice does still appear ?

Would you be willing to check in a different way for me ? I'd really like to help you get this solved, but as I can't reproduce the issue, I can't test things myself.

If you're willing, could you try (temporarily) replacing the below code in the log-deprecated-notices/log-deprecated-notices.php file around line 241 so we can find out what deprecated call is causing the notices and why the deprecate notices backtrace isn't working:

function log_wrong( $function, $message, $version ) {
    $backtrace = debug_backtrace();
    $deprecated = $function . '()';
    $in_file = $this->strip_abspath( $backtrace[ 4 ]['file'] );
    $on_line = $backtrace[ 4 ]['line'];
    $this->log( 'wrong', compact( 'deprecated', 'message', 'version', 'in_file', 'on_line' ) );
}

with:

function log_wrong( $function, $message, $version ) {
trigger_error( 'Notice caused by : ' . $function . ' with message : ' . $message . ' and version : ' . $version, E_USER_NOTICE );
    $backtrace = debug_backtrace();
print '<pre>';
print_r( $backtrace );
print '</pre>';
    $deprecated = $function . '()';
    $in_file = $this->strip_abspath( $backtrace[ 4 ]['file'] );
    $on_line = $backtrace[ 4 ]['line'];
    $this->log( 'wrong', compact( 'deprecated', 'message', 'version', 'in_file', 'on_line' ) );
}
@satrya

Oh, maybe the notice are from bbPress? I got this


Notice: Notice caused by : bbp_setup_current_user with message : The current user is being initialized without using $wp->init(). and version : 2.3 in D:\xampp\htdocs\themephe\wp-content\plugins\log-deprecated-notices\log-deprecated-notices.php on line 242
Array
(
    [0] => Array
        (
            [function] => log_wrong
            [class] => Deprecated_Log
            [object] => Deprecated_Log Object
                (
                    [options] => Array
                        (
                            [last_viewed] => 2014-03-19 21:34:54
                            [db_version] => 4
                        )

                    [queued_posts] => Array
                        (
                        )

                )

            [type] => ->
            [args] => Array
                (
                    [0] => bbp_setup_current_user
                    [1] => The current user is being initialized without using $wp->init().
                    [2] => 2.3
                )

        )

    [1] => Array
        (
            [file] => D:\xampp\htdocs\themephe\wp-includes\plugin.php
            [line] => 429
            [function] => call_user_func_array
            [args] => Array
                (
                    [0] => Array
                        (
                            [0] => Deprecated_Log Object
                                (
                                    [options] => Array
                                        (
                                            [last_viewed] => 2014-03-19 21:34:54
                                            [db_version] => 4
                                        )

                                    [queued_posts] => Array
                                        (
                                        )

                                )

                            [1] => log_wrong
                        )

                    [1] => Array
                        (
                            [0] => bbp_setup_current_user
                            [1] => The current user is being initialized without using $wp->init().
                            [2] => 2.3
                        )

                )

        )

    [2] => Array
        (
            [file] => D:\xampp\htdocs\themephe\wp-includes\functions.php
            [line] => 3042
            [function] => do_action
            [args] => Array
                (
                    [0] => doing_it_wrong_run
                    [1] => bbp_setup_current_user
                    [2] => The current user is being initialized without using $wp->init().
                    [3] => 2.3
                )

        )

    [3] => Array
        (
            [file] => D:\xampp\htdocs\themephe\wp-content\plugins\bbpress\includes\core\sub-actions.php
            [line] => 147
            [function] => _doing_it_wrong
            [args] => Array
                (
                    [0] => bbp_setup_current_user
                    [1] => The current user is being initialized without using $wp->init().
                    [2] => 2.3
                )

        )

    [4] => Array
        (
            [function] => bbp_setup_current_user
            [args] => Array
                (
                    [0] => 
                )

        )

    [5] => Array
        (
            [file] => D:\xampp\htdocs\themephe\wp-includes\plugin.php
            [line] => 429
            [function] => call_user_func_array
            [args] => Array
                (
                    [0] => bbp_setup_current_user
                    [1] => Array
                        (
                            [0] => 
                        )

                )

        )

    [6] => Array
        (
            [file] => D:\xampp\htdocs\themephe\wp-includes\pluggable.php
            [line] => 37
            [function] => do_action
            [args] => Array
                (
                    [0] => set_current_user
                )

        )

    [7] => Array
        (
            [file] => D:\xampp\htdocs\themephe\wp-includes\pluggable.php
            [line] => 107
            [function] => wp_set_current_user
            [args] => Array
                (
                    [0] => 1
                )

        )

    [8] => Array
        (
            [file] => D:\xampp\htdocs\themephe\wp-includes\pluggable.php
            [line] => 54
            [function] => get_currentuserinfo
            [args] => Array
                (
                )

        )

    [9] => Array
        (
            [file] => D:\xampp\htdocs\themephe\wp-includes\capabilities.php
            [line] => 1342
            [function] => wp_get_current_user
            [args] => Array
                (
                )

        )

    [10] => Array
        (
            [file] => D:\xampp\htdocs\themephe\wp-content\plugins\wordpress-seo\inc\class-wpseo-options.php
            [line] => 3380
            [function] => current_user_can
            [args] => Array
                (
                    [0] => manage_options
                )

        )

    [11] => Array
        (
            [file] => D:\xampp\htdocs\themephe\wp-content\plugins\wordpress-seo\admin\class-admin.php
            [line] => 34
            [function] => grant_access
            [class] => WPSEO_Options
            [type] => ::
            [args] => Array
                (
                )

        )

    [12] => Array
        (
            [file] => D:\xampp\htdocs\themephe\wp-content\plugins\wordpress-seo\wp-seo-main.php
            [line] => 220
            [function] => __construct
            [class] => WPSEO_Admin
            [object] => WPSEO_Admin Object
                (
                )

            [type] => ->
            [args] => Array
                (
                )

        )

    [13] => Array
        (
            [function] => wpseo_admin_init
            [args] => Array
                (
                    [0] => 
                )

        )

    [14] => Array
        (
            [file] => D:\xampp\htdocs\themephe\wp-includes\plugin.php
            [line] => 429
            [function] => call_user_func_array
            [args] => Array
                (
                    [0] => wpseo_admin_init
                    [1] => Array
                        (
                            [0] => 
                        )

                )

        )

    [15] => Array
        (
            [file] => D:\xampp\htdocs\themephe\wp-settings.php
            [line] => 231
            [function] => do_action
            [args] => Array
                (
                    [0] => plugins_loaded
                )

        )

    [16] => Array
        (
            [file] => D:\xampp\htdocs\themephe\wp-config.php
            [line] => 99
            [args] => Array
                (
                    [0] => D:\xampp\htdocs\themephe\wp-settings.php
                )

            [function] => require_once
        )

    [17] => Array
        (
            [file] => D:\xampp\htdocs\themephe\wp-load.php
            [line] => 29
            [args] => Array
                (
                    [0] => D:\xampp\htdocs\themephe\wp-config.php
                )

            [function] => require_once
        )

    [18] => Array
        (
            [file] => D:\xampp\htdocs\themephe\wp-admin\admin.php
            [line] => 30
            [args] => Array
                (
                    [0] => D:\xampp\htdocs\themephe\wp-load.php
                )

            [function] => require_once
        )

    [19] => Array
        (
            [file] => D:\xampp\htdocs\themephe\wp-admin\plugins.php
            [line] => 10
            [args] => Array
                (
                    [0] => D:\xampp\htdocs\themephe\wp-admin\admin.php
                )

            [function] => require_once
        )

)
@jrfnl jrfnl added a commit to jrfnl/wordpress-seo that referenced this issue Mar 21, 2014
@jrfnl jrfnl `current_user_can()` was being called too early
Related issues #881, #565
bdb777b
@jrfnl

Great stuff! Thanks for that. The issue is caused by a buggy doing_it_wrong in bbPress as also discussed in issue #565. All the same, your trace has now helped me identify where WPSEO was supposedly 'doing it wrong' and I've send in pull request #898 to avoid further warnings.

All the same bbPress is doing something funky which causes the error in Log Deprecated notices, but at least bbPress shouldn't be giving that warning anymore because of WPSEO. In other cases where bbPress gives that warning, you will probably still see the PHP notices in the Log Deprecated plugin.

@satrya

Cool, I tried your PR codes and the notices disappear 👍

Thanks @jrfnl

@jrfnl

@satrya Thank you for testing & confirming ;-)

@satrya

you're welcome, glad to help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment