xwp / stream

🗄️ Stream plugin for WordPress
https://wordpress.org/plugins/stream/
GNU General Public License v2.0
405 stars 119 forks source link

CLI: PHP Uncaught TypeError #1474

Closed Soean closed 3 weeks ago

Soean commented 5 months ago

Bug Report

If I type wp stream query on the CLI, I get an PHP error.

Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, stdClass given in /wp-content/plugins/stream/classes/class-cli.php:137

Possible Fix

A record is an Object, not an Array, so we should use property_exists() instead array_key_exists.

Before

foreach ( $fields as $field ) {
    if ( ! array_key_exists( $field, $record ) ) {
        $record->$field = null;
    }
}

After

foreach ( $fields as $field ) {
    if ( ! property_exists( $record, $field ) ) {
        $record->$field = null;
    }
}

System Information

roborourke commented 1 month ago

I hit this one on VIP hosting just now too. Will be good to get this fix merged.