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
The wp user session list command in WP-CLI supports a --fields parameter which allows you to include your custom field in the output. Example:
wp user session list john --fields=custom,login_time
+--------+---------------------+
| custom | login_time |
+--------+---------------------+
| 123 | 2018-09-15 14:28:56 |
+--------+---------------------+
Unfortunately, WP-CLI is a little over-zealous with its field name validation. If any session in the result set does not contain a field called custom, the command fails with the error:
Error: Invalid field: custom.
This situation is easy to experience. Any session that existed before the custom field was implemented will cause the command to fail. Alternatively, if the addition of the custom field is conditional then any session which doesn't get the field attached will also cause the command to fail.
I think the solution is to remove the field name validation, but this may introduce problems with data validation. Suggestions welcome.
The text was updated successfully, but these errors were encountered:
Shouldn't it be enough to change the validation from "all sessions must contain field" to "at least one session must contain field"? The sessions that don't contain the field can default to just be empty then.
That will still trigger the error in the situation where none of the sessions contain the field.
The problem is that user sessions don't have the concept of meta data - custom fields are first class properties of the session, but their keys are arbitrary.
I think it would make the most sense to remove the custom field name validation, and simply return an empty value for each session that doesn't include that field. Not ideal though.
When a user session is created, it's possible to add custom fields to the session via the
attach_session_information
filter. Example:The
wp user session list
command in WP-CLI supports a--fields
parameter which allows you to include your custom field in the output. Example:Unfortunately, WP-CLI is a little over-zealous with its field name validation. If any session in the result set does not contain a field called
custom
, the command fails with the error:This situation is easy to experience. Any session that existed before the custom field was implemented will cause the command to fail. Alternatively, if the addition of the custom field is conditional then any session which doesn't get the field attached will also cause the command to fail.
I think the solution is to remove the field name validation, but this may introduce problems with data validation. Suggestions welcome.
The text was updated successfully, but these errors were encountered: