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
I've searched for any related issues and avoided creating a duplicate issue.
Please give us a description of what happened
When editing a post, the following fatal error occurs, preventing the page from loading properly: Uncaught TypeError: array_column(): Argument #1 ($array) must be of type array, bool given in /var/www/wp-content/plugins/wordpress-seo/inc/class-wpseo-meta.php:1028
The error happens when $repository->query()->select()->where_in()->find_array() in class-wpseo-meta.php fails and returns false. This causes array_column() to throw a TypeError, as it expects an array.
To Reproduce
Step-by-step reproduction instructions
Install and activate the Yoast SEO plugin version 24.0.
Use the Divi theme (version 4.27.4).
Edit any post in the WordPress dashboard.
Observe the error displayed in the logs and inability to proceed.
Expected results
The page should load without errors, and the plugin should handle cases where $repository->query()->select()->where_in()->find_array() fails gracefully by defaulting to an empty array.
Actual results
The error blocks functionality, specifically in the WordPress editor, and the page does not load as expected.
Uncaught TypeError: array_column(): Argument #1 ($array) must be of type array, bool given in /var/www/wp-content/plugins/wordpress-seo/inc/class-wpseo-meta.php:1028
Stack trace:
#0 ...
Suggested fix
The issue can be resolved by validating the $post_types variable before passing it to array_column(). Below is the adjusted code for the affected block in class-wpseo-meta.php:
// Check if post ids is not empty.
if ( ! empty( $post_ids ) ) {
// Get the post subtypes for the posts that share the keyword.
$post_types = $repository->query()
->select( 'object_sub_type' )
->where_in( 'object_id', $post_ids )
->find_array();
// Ensure $post_types is an array before using array_column().
if ( is_array( $post_types ) ) {
// Get object_sub_type from each subarray in $post_types.
$post_types = array_column( $post_types, 'object_sub_type' );
} else {
// Default to an empty array if the query fails.
$post_types = [];
}
} else {
$post_types = [];
}
return $post_types;
Technical info
If relevant, which editor is affected (or editors):
Block Editor
Gutenberg Editor
Elementor Editor
Classic Editor
Other:
Which browser is affected (or browsers):
Chrome
Firefox
Safari
Other:
Used versions
Device you are using:
Operating system:
PHP version: 8.0.30
WordPress version: 6.6.2
WordPress Theme: Divi (version 4.27.4)
Yoast SEO version: 24.0
Gutenberg plugin version:
Elementor plugin version:
Classic Editor plugin version:
Relevant plugins in case of a bug:
The text was updated successfully, but these errors were encountered:
Thanks for reporting this issue. I tested this on my lab site and noticed that the edit post loads without fatal errors with Yoast SEO 24.0 and Divi theme 4.27.4. So, could you let me know whether you have tested this case on a fresh WP installation without any other plugins active besides Yoast SEO? If not, please try this again and let us know the results or whether you missed any steps.
We look forward to hearing from you and are happy to help you.
Please give us a description of what happened
When editing a post, the following fatal error occurs, preventing the page from loading properly:
Uncaught TypeError: array_column(): Argument #1 ($array) must be of type array, bool given in /var/www/wp-content/plugins/wordpress-seo/inc/class-wpseo-meta.php:1028
The error happens when $repository->query()->select()->where_in()->find_array() in class-wpseo-meta.php fails and returns false. This causes array_column() to throw a TypeError, as it expects an array.
To Reproduce
Step-by-step reproduction instructions
Expected results
Actual results
Screenshots, screen recording, code snippet
Error Details
File: /var/www/wp-content/plugins/wordpress-seo/inc/class-wpseo-meta.php
Line: 1028
Stack Trace:
Suggested fix
The issue can be resolved by validating the $post_types variable before passing it to array_column(). Below is the adjusted code for the affected block in class-wpseo-meta.php:
Technical info
Used versions
The text was updated successfully, but these errors were encountered: