Prerequisites
Summary
We are regularly encountering the following PHP warning with Yoast SEO 28.2:
PHP Warning [2]: Array to string conversion
The warning originates from:
wp-content/plugins/wordpress-seo/inc/sitemaps/class-sitemaps-cache.php
at approximately line 206, in the invalidate_helper() method.
Environment
Plugin: Yoast SEO 28.2
WooCommerce 11.0.1
PHP: 8.3
WordPress: WordPress 7.0.3
The issue occurs repeatedly during automated WooCommerce product updates.
Error
The reported error is:
PHP Error [2] Array to string conversion
Location:
wp-content/plugins/wordpress-seo/inc/sitemaps/class-sitemaps-cache.php
The relevant code is:
public static function invalidate_helper( $unused, $type ) {
if (
WPSEO_Options::get( 'noindex-' . $type ) === false
|| WPSEO_Options::get( 'noindex-tax-' . $type ) === false
) {
self::invalidate( $type );
}
}
The warning is triggered when $type is an array rather than a string.
In particular, these expressions implicitly convert $type to a string:
'noindex-' . $type
and
'noindex-tax-' . $type
which produces the PHP warning:
Array to string conversion
Hooks involved
invalidate_helper() is registered on the following WordPress hooks:
add_action( 'edited_terms', [ self::class, 'invalidate_helper' ], 10, 2 );
add_action( 'clean_term_cache', [ self::class, 'invalidate_helper' ], 10, 2 );
add_action( 'clean_object_term_cache', [ self::class, 'invalidate_helper' ], 10, 2 );
The problematic case appears to involve:
clean_object_term_cache
where the second argument ($object_type) can be an array of taxonomy names in some WordPress/WooCommerce execution paths.
invalidate_helper() currently assumes that $type is always a scalar string.
Doc: https://developer.wordpress.org/reference/functions/clean_object_term_cache/
Step-by-step reproduction instructions
The warning occurs during an automated process that updates WooCommerce products.
During the same request, several product taxonomies can be modified for the same product, including, the update pipeline performs operations equivalent to:
wp_set_object_terms( $product_id, ..., 'xxxxxx' );
wp_set_object_terms( $product_id, ..., 'yyyyyyyy' );
wp_set_object_terms( $product_id, ..., 'zzzzz' );
Additionally, WooCommerce product saving can modify the product_type taxonomy:
$product->save();
which can ultimately call:
wp_set_object_terms( $product_id, 'external', 'product_type' );
When these operations occur in the same execution flow, WordPress can reach clean_object_term_cache() with multiple taxonomies represented as an array.
Yoast SEO then receives that array as $type through:
invalidate_helper( $unused, $type )
and attempts:
'noindex-' . $type
resulting in:
Array to string conversion
Expected results
Yoast SEO should handle the value received from the WordPress hook safely.
If $type is an array containing multiple taxonomies, Yoast should either:
process each taxonomy individually, or
safely ignore unsupported/unexpected values.
In either case, updating or invalidating WooCommerce product term caches should not generate a PHP warning.
Actual behavior
When $type is an array, Yoast executes:
WPSEO_Options::get( 'noindex-' . $type )
which causes:
PHP Warning: Array to string conversion
The warning can occur repeatedly during automated product updates and creates noise in PHP/application logs.
Actual results
- PHP Error [2] Array to string conversion
Screenshots, screen recording, code snippet
A robust implementation could explicitly handle arrays.
For example:
public static function invalidate_helper( $unused, $type ) {
foreach ( (array) $type as $taxonomy ) {
if (
WPSEO_Options::get( 'noindex-' . $taxonomy ) === false
|| WPSEO_Options::get( 'noindex-tax-' . $taxonomy ) === false
) {
self::invalidate( $taxonomy );
}
}
}
Alternatively, if Yoast expects this hook to always provide a single taxonomy, the method could explicitly validate the argument:
if ( ! is_string( $type ) ) {
return;
}
However, iterating over the array would likely be preferable if WordPress can legitimately provide multiple taxonomy names, because it preserves the cache invalidation behavior for every taxonomy.
Why we believe this is a Yoast SEO compatibility/robustness issue
The application code is modifying several WooCommerce taxonomies, but it does not directly concatenate or otherwise convert taxonomy arrays to strings.
The warning is generated inside Yoast SEO because invalidate_helper() assumes that the $type parameter is always a string.
The method does not currently perform any type validation before using $type in string concatenation.
Therefore, the underlying trigger is the interaction between WordPress/WooCommerce taxonomy cache invalidation and Yoast's invalidate_helper() implementation.
Which editor is affected (or editors)
Which browser is affected (or browsers)
Device you are using
No response
Operating system
No response
PHP version
8.3
WordPress version
7.0.3
WordPress Theme
No response
Yoast SEO version
28.2
Gutenberg plugin version (if relevant)
No response
Elementor plugin version (if relevant)
No response
Classic Editor plugin version (if relevant)
No response
Relevant plugins in case of a bug
WooCommerce 11.0.1
Prerequisites
Summary
We are regularly encountering the following PHP warning with Yoast SEO 28.2:
PHP Warning [2]: Array to string conversion
The warning originates from:
wp-content/plugins/wordpress-seo/inc/sitemaps/class-sitemaps-cache.php
at approximately line 206, in the invalidate_helper() method.
Environment
Plugin: Yoast SEO 28.2
WooCommerce 11.0.1
PHP: 8.3
WordPress: WordPress 7.0.3
The issue occurs repeatedly during automated WooCommerce product updates.
Error
The reported error is:
PHP Error [2] Array to string conversion
Location:
wp-content/plugins/wordpress-seo/inc/sitemaps/class-sitemaps-cache.php
The relevant code is:
The warning is triggered when $type is an array rather than a string.
In particular, these expressions implicitly convert $type to a string:
'noindex-' . $type
and
'noindex-tax-' . $type
which produces the PHP warning:
Array to string conversion
Hooks involved
invalidate_helper() is registered on the following WordPress hooks:
add_action( 'edited_terms', [ self::class, 'invalidate_helper' ], 10, 2 );
add_action( 'clean_term_cache', [ self::class, 'invalidate_helper' ], 10, 2 );
add_action( 'clean_object_term_cache', [ self::class, 'invalidate_helper' ], 10, 2 );
The problematic case appears to involve:
clean_object_term_cache
where the second argument ($object_type) can be an array of taxonomy names in some WordPress/WooCommerce execution paths.
invalidate_helper() currently assumes that $type is always a scalar string.
Doc: https://developer.wordpress.org/reference/functions/clean_object_term_cache/
Step-by-step reproduction instructions
The warning occurs during an automated process that updates WooCommerce products.
During the same request, several product taxonomies can be modified for the same product, including, the update pipeline performs operations equivalent to:
wp_set_object_terms( $product_id, ..., 'xxxxxx' );
wp_set_object_terms( $product_id, ..., 'yyyyyyyy' );
wp_set_object_terms( $product_id, ..., 'zzzzz' );
Additionally, WooCommerce product saving can modify the product_type taxonomy:
$product->save();
which can ultimately call:
wp_set_object_terms( $product_id, 'external', 'product_type' );
When these operations occur in the same execution flow, WordPress can reach clean_object_term_cache() with multiple taxonomies represented as an array.
Yoast SEO then receives that array as $type through:
invalidate_helper( $unused, $type )
and attempts:
'noindex-' . $type
resulting in:
Array to string conversion
Expected results
Yoast SEO should handle the value received from the WordPress hook safely.
If $type is an array containing multiple taxonomies, Yoast should either:
process each taxonomy individually, or
safely ignore unsupported/unexpected values.
In either case, updating or invalidating WooCommerce product term caches should not generate a PHP warning.
Actual behavior
When $type is an array, Yoast executes:
WPSEO_Options::get( 'noindex-' . $type )
which causes:
PHP Warning: Array to string conversion
The warning can occur repeatedly during automated product updates and creates noise in PHP/application logs.
Actual results
Screenshots, screen recording, code snippet
A robust implementation could explicitly handle arrays.
For example:
Alternatively, if Yoast expects this hook to always provide a single taxonomy, the method could explicitly validate the argument:
However, iterating over the array would likely be preferable if WordPress can legitimately provide multiple taxonomy names, because it preserves the cache invalidation behavior for every taxonomy.
Why we believe this is a Yoast SEO compatibility/robustness issue
The application code is modifying several WooCommerce taxonomies, but it does not directly concatenate or otherwise convert taxonomy arrays to strings.
The warning is generated inside Yoast SEO because invalidate_helper() assumes that the $type parameter is always a string.
The method does not currently perform any type validation before using $type in string concatenation.
Therefore, the underlying trigger is the interaction between WordPress/WooCommerce taxonomy cache invalidation and Yoast's invalidate_helper() implementation.
Which editor is affected (or editors)
Which browser is affected (or browsers)
Device you are using
No response
Operating system
No response
PHP version
8.3
WordPress version
7.0.3
WordPress Theme
No response
Yoast SEO version
28.2
Gutenberg plugin version (if relevant)
No response
Elementor plugin version (if relevant)
No response
Classic Editor plugin version (if relevant)
No response
Relevant plugins in case of a bug
WooCommerce 11.0.1