Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: PHP Uncaught TypeError #1474

Open
Soean opened this issue Jan 12, 2024 · 0 comments · May be fixed by #1475
Open

CLI: PHP Uncaught TypeError #1474

Soean opened this issue Jan 12, 2024 · 0 comments · May be fixed by #1475

Comments

@Soean
Copy link

Soean commented Jan 12, 2024

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

  • Stream plugin version: 4.0.0
  • WordPress version: 6.4.2
  • PHP version: 8.2
  • WP-CLI: 2.9.0
@Soean Soean linked a pull request Jan 12, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant