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
Results from $wpdb->get_results( $query ) default to $output of OBJECT. Line 137 of class-cli.php then calls array_key_exists( $field, $record ) where $record is an object instead of an array.
Possible Fixes
Return the results as an associative array $wpdb->get_results( $query, ARRAY_A ) in \WP_Stream\Query->query()
Use property_exists( $record, $field ) instead of array_key_exists in \WP_Stream\CLI->query()
Expected Behavior
Run the query WP-CLI stream command:
$ wp stream query
+---------------------+-----------+---------+---------------+-------------------------------------------------+
| created | ip | user_id | user_role | summary |
+---------------------+-----------+---------+---------------+-------------------------------------------------+
...
+---------------------+-----------+---------+---------------+-------------------------------------------------+
Actual Behavior
Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, stdClass given .../wp-content/plugins/stream/classes/class-cli.php(137): array_key_exists()
Steps to Reproduce the Problem
Run wp stream query via WP-CLI
View debug/error
System Information
Stream plugin version: 3.9.3
WordPress version: 6.1.1/6.2
PHP version: 8.0/8.1
Browser: CLI
Computer operating system: N/A
The text was updated successfully, but these errors were encountered:
PHP Deprecated: array_key_exists(): Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead in /Users/jerryprice/Sites/bn/wp-content/plugins/stream/classes/class-cli.php on line 137
Bug Report
The issue is inside
\WP_Stream\CLI->query()
:wp_stream_get_instance()->db->query()
calls\WP_Stream\Query->query()
:Results from
$wpdb->get_results( $query )
default to$output
ofOBJECT
. Line 137 of class-cli.php then callsarray_key_exists( $field, $record )
where $record is an object instead of an array.Possible Fixes
$wpdb->get_results( $query, ARRAY_A )
in\WP_Stream\Query->query()
property_exists( $record, $field )
instead of array_key_exists in\WP_Stream\CLI->query()
Expected Behavior
Run the
query
WP-CLI stream command:Actual Behavior
Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, stdClass given
.../wp-content/plugins/stream/classes/class-cli.php(137): array_key_exists()
Steps to Reproduce the Problem
wp stream query
via WP-CLISystem Information
The text was updated successfully, but these errors were encountered: