You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
wp user session list fatals with TypeError when a session token has a non-int expiration #622
wp user session list <user> throws a fatal TypeError under PHP 8+ when any of the user's session tokens has an expiration (or login) value that is not an int. A single malformed token takes down the entire command.
Stack trace (WP-CLI 2.12.0, entity-command)
PHP Fatal error: Uncaught TypeError: date(): Argument #2 ($timestamp) must be of type ?int, string given
in .../wp-cli/entity-command/src/User_Session_Command.php:184
#0 User_Session_Command.php(184): date()
#1 {closure:User_Session_Command::get_all_sessions():181}()
#2 User_Session_Command.php(179): array_walk()
#3 User_Session_Command.php(164): User_Session_Command->get_all_sessions()
#4 User_Session_Command->list_()
date()'s second argument is typed ?int. Under PHP 7 a non-numeric string was silently coerced to 0; under PHP 8 it is a hard TypeError, so the whole command dies instead of listing the user's sessions.
How the bad data arises
Session token internals live in session_tokens user meta and are normally written by core with integer expiration/login. But WP-CLI cannot assume every token in the wild is well-formed — plugins, imports, or edge-case auth paths can leave a token whose expiration is a string. In our case one token had expiration => 'logged_in' (the auth cookie scheme string landed in the expiration slot), UA WP CLI 2.12.0. That single token made wp user session list unusable for that user until we manually pruned the meta.
Impact
Command is completely unusable for the affected user (no way to see the sessions in order to destroy the bad one via wp user session destroy).
On multisite, session_tokens is global usermeta, so one bad token surfaces the fatal from every site context.
Suggested fix
Guard the date formatting so a malformed token degrades gracefully instead of fataling the whole list. For example:
I would be interested in knowing how this could potentially occur. Is it a widespread problem or a one-off issue specific to your site?
I'm asking because WP-CLI can't possibly add defensive checks like this in every possible command and code branch. In this particular case I tend to think WP-CLI should really be able to trust the data in session_tokens.
This particular piece of code has existed like this for 10+ years, so to me it really sounds more like a one-off issue specific to your site.
@swissspidy It's probably a one-off specific to my setup, but could become more common if more people run agents on a VPS alongside their WordPress sites.
I'm pretty sure this happened because Claude bypassed WordPress to write the non-integer token directly to the database. It had been sitting there for months (March 29th), and tripped me up while setting up some analytics code.
Happy to close it if you don't think it's worth a fix. I had a similar thought about this one, which is why I didn't open a PR for it.
In that case let's close it for now. We can always reopen if this becomes more widespread.
Dealing with the aftermath of AI hallucinations shouldn't be WP-CLI's job IMO. But it could mean there is a need for improved documentation in WordPress core itself.
Activity
swissspidy commentedon Jul 12, 2026
Thanks for your report!
I would be interested in knowing how this could potentially occur. Is it a widespread problem or a one-off issue specific to your site?
I'm asking because WP-CLI can't possibly add defensive checks like this in every possible command and code branch. In this particular case I tend to think WP-CLI should really be able to trust the data in
session_tokens.This particular piece of code has existed like this for 10+ years, so to me it really sounds more like a one-off issue specific to your site.
chubes4 commentedon Jul 12, 2026
@swissspidy It's probably a one-off specific to my setup, but could become more common if more people run agents on a VPS alongside their WordPress sites.
I'm pretty sure this happened because Claude bypassed WordPress to write the non-integer token directly to the database. It had been sitting there for months (March 29th), and tripped me up while setting up some analytics code.
Happy to close it if you don't think it's worth a fix. I had a similar thought about this one, which is why I didn't open a PR for it.
swissspidy commentedon Jul 12, 2026
In that case let's close it for now. We can always reopen if this becomes more widespread.
Dealing with the aftermath of AI hallucinations shouldn't be WP-CLI's job IMO. But it could mean there is a need for improved documentation in WordPress core itself.