Skip to content

Fix PHP Warning when accessing user_login property on boolean#25

Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1748224741-fix-user-login-warning
Open

Fix PHP Warning when accessing user_login property on boolean#25
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1748224741-fix-user-login-warning

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

Fix PHP Warning when accessing user_login property on boolean

Issue

Fixes #24

This PR addresses a PHP Warning that occurs when attempting to read the property "user_login" on a boolean value within the Shifter WordPress MU plugin.

Root Cause

The notify_logout method in class-shifter-api.php doesn't validate the result of get_user_by('ID', $user_id) before attempting to access the user_login property. When an invalid user ID is passed, get_user_by() returns false, causing a PHP warning.

Solution

Added validation to check if $user is a valid user object before accessing its properties. The method now gracefully handles cases where get_user_by() returns false without throwing PHP warnings.

Testing

The fix has been tested by verifying that:

  • The code properly handles cases where get_user_by() returns false
  • No PHP warnings are generated when an invalid user ID is passed to the notify_logout method

Link to Devin run

https://app.devin.ai/sessions/c8ccda563c184048acd7683871e96dab

Requested by: hidetaka@digitalcube.jp

Co-Authored-By: hidetaka@digitalcube.jp <hidetaka@digitalcube.jp>
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PHP Warning in notify_logout method

0 participants