Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent PHP warnings when no WordPress user is found #25477

Merged
merged 1 commit into from
Jan 31, 2023

Conversation

christianwach
Copy link
Member

Overview

When no WordPress user is found, PHP warnings are issued:

Warning: Attempt to read property "data" on bool
Warning: Attempt to read property "ID" on bool

Additionally, the WP_User object has magic methods for retrieving the ID directly, so there is no need to look in the data property.

Before

PHP warnings are issued.

After

No PHP warnings are issued.

Comments

IMO too minor a fix to open an issue on Lab.

@civibot
Copy link

civibot bot commented Jan 31, 2023

(Standard links)

@civibot civibot bot added the master label Jan 31, 2023
@kcristiano
Copy link
Member

kcristiano commented Jan 31, 2023

This looks good to me. Not sure why that test failed.

@totten
Copy link
Member

totten commented Jan 31, 2023

Ah, looks pretty sensible.

https://developer.wordpress.org/reference/classes/wp_user/ says ->ID is very slightly newer... going back to WP v2.1.0. 🙃

Test failure is probably unrelated. Fired a manual supplement to be sure (https://test.civicrm.org/job/CiviCRM-Manual-Test/39/), and that passed.

@totten totten merged commit 42c7e5e into civicrm:master Jan 31, 2023
@christianwach christianwach deleted the userdata branch February 7, 2024 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants