Repository navigation
Description
Bug Report
- Yes, I reviewed the contribution guidelines.
- Yes, more specifically, I reviewed the guidelines on how to write clear bug reports.
Describe the current, buggy behavior
The issue was found by a human on our hosting servers; the analysis and text of this report were written with Claude.
Since #6255 (--context=auto is the default), every wp plugin … / wp theme … command runs in the admin context. Context\Admin::log_in_as_admin_user() calls wp_generate_auth_cookie() twice without a $token. Core then creates a new session via WP_Session_Tokens::create() each time.
Result: every call stores two sessions (valid 24 h, IP 127.0.0.1, UA WP CLI …) for the first admin. A cron job running wp plugin list every few minutes left 100–200 "unknown" sessions per admin on our sites.
Describe how other contributors can replicate this bug
wp user session list <admin> # n
wp plugin list > /dev/null
wp user session list <admin> # n + 2Describe what you would expect as the correct outcome
Destroy the token at shutdown, or use a non-persistent token manager (session_token_manager filter) while in the admin context.
Let us know what environment you are running this on
OS: Linux 6.12.111+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.111-1 (2026-09-28) x86_64
Shell: /bin/bash
PHP binary: /usr/bin/php8.5
PHP version: 8.5.11
PHP memory limit: -1
php.ini used: /etc/php/8.5/cli/php.ini
MySQL binary: /usr/bin/mariadb
MySQL version: mariadb from 11.8.9-MariaDB, client 15.2 for debian-linux-gnu (x86_64) using EditLine wrapper
SQL modes: STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: phar:///usr/local/bin/wp
WP-CLI packages dir:
WP-CLI cache dir: /root/.wp-cli/cache
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 3.0.0-alpha-3225c03
Provide a possible solution
Destroy the token at shutdown, or use a non-persistent token manager (session_token_manager filter) while in the admin context.
Activity
Avoid leaving persistent session tokens behind in admin context (#6436)
Avoid leaving persistent session tokens behind in admin context (#6436)
Avoid leaving persistent session tokens behind in admin context (#6436)
Avoid leaving persistent session tokens behind in admin context (#6436)