Skip to content

Undefined property: stdClass::$role warning before headers are sent causes issue when saving my profile. #174

@trevormills-xwp

Description

@trevormills-xwp

If error_reporting includes Warnings, then when I save my profile ( from wp-admin/profile.php ), there is a Warning emitted before headers are sent, causing the page to whitescreen ( except for the error ) when it tries to send headers.

The warning is:

Warning: Undefined property: stdClass::$role in /var/www/html/wp-content/plugins/authorship/inc/admin.php on line 42 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/plugins/authorship/inc/admin.php:42) in /var/www/html/wp/wp-includes/pluggable.php on line 1531 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/plugins/authorship/inc/admin.php:42) in /var/www/html/wp/wp-includes/pluggable.php on line 1534

Fix, I think, is to change this:

	if ( $user->role !== GUEST_ROLE ) {
		return;
	}

... to this:

	if ( ! isset( $user->role ) || ( $user->role !== GUEST_ROLE ) ) {
		return;
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions