Commit 9ecae09
Fix PHP warning when deleting users without co-author terms
Fixes #1165
When deleting WordPress users, a PHP 8.4 warning was occurring:
"Attempt to read property 'term_id' on bool" at line 1127 in
class-coauthors-plus.php.
The issue occurred because `get_author_term()` can return `false` when
a user doesn't have a corresponding co-author term (e.g., if the term
was manually deleted or the user was created outside the co-authors
system). The code attempted to access `$term->term_id` without checking
if `$term` was valid.
This fix adds a null check before attempting to delete the term,
preventing the warning while maintaining the same functional behavior.
A new integration test reproduces the bug scenario and verifies the fix.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent c245959 commit 9ecae09
File tree
2 files changed
+45
-1
lines changed- php
- tests/Integration
2 files changed
+45
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1124 | 1124 | | |
1125 | 1125 | | |
1126 | 1126 | | |
1127 | | - | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
1128 | 1130 | | |
1129 | 1131 | | |
1130 | 1132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1993 | 1993 | | |
1994 | 1994 | | |
1995 | 1995 | | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
1996 | 2038 | | |
0 commit comments