stream
stream copied to clipboard
PHP Fatal error: Uncaught ValueError w/ Yosat SEO
Bug Report
Expected Behavior
Clicking publish post doesn't generate a fatal error.
Actual Behavior
Clicking publish triggers a fatal error.
Steps to Reproduce the Problem
- Add title/content
- Update Yoast SEO meta
- Publish
Screenshots
PHP Fatal error: Uncaught ValueError: Unknown format specifier "N" in /wp-content/plugins/stream/classes/class-log.php:139
Stack trace:
#0 //wp-content/plugins/stream/classes/class-log.php(139): vsprintf('Updated "Meta d...', Array)
#1 [internal function]: WP_Stream\Log->log('wordpressseo', 'Updated "Meta d...', Array, 97977, 'wpseo_meta', 'updated', 691)
#2 //wp-content/plugins/stream/classes/class-connector.php(178): call_user_func_array(Array, Array)
#3 //wp-content/plugins/stream/connectors/class-connector-wordpress-seo.php(433): WP_Stream\Connector->log('Updated "Meta d...', Array, 97977, 'wpseo_meta', 'updated')
#4 //wp-content/plugins/stream/connectors/class-connector-wordpress-seo.php(353): WP_Stream\Connector_WordPress_SEO->meta(97977, '_yoast_wpseo_me...', 'TerrAscend said...')
#5 [internal function]: WP_Stream\Connector_WordPress_SEO->callback_added_post_meta(NULL, 97977, '_yoast_wpseo_me...', 'TerrAscend said...')
#6 //wp-content/plugins/stream/classes/class-connector.php(127): call_user_func_array(Array, Array)
System Information
- Stream plugin version: 3.9.3
- Yoast: 20.12
- Yoast Premium: 20.11
- WordPress version: 6.1.3
- PHP version: 8.0.22
- Browser: NA
- Computer operating system: Linux
Hello,
Same error here, even on lastest Stream (3.10.0) version :
Uncaught ValueError: Unknown format specifier "m" in /home/wordpress/public_html/web/app/plugins/stream/classes/class-log.php:139
Stack trace:
#0 /home/wordpress/public_html/web/app/plugins/stream/classes/class-log.php(139): vsprintf()
#1 [internal function]: WP_Stream\Log->log()
#2 /home/wordpress/public_html/web/app/plugins/stream/classes/class-connector.php(178): call_user_func_array()
#3 /home/wordpress/public_html/web/app/plugins/stream/connectors/class-connector-wordpress-seo.php(433): WP_Stream\Connector->log()
#4 /home/wordpress/public_html/web/app/plugins/stream/connectors/class-connector-wordpress-seo.php(368): WP_Stream\Connector_WordPress_SEO->meta()
#5 [internal function]: WP_Stream\Connector_WordPress_SEO->callback_updated_post_meta()
#6 /home/wordpress/public_html/web/app/plugins/stream/classes/class-connector.php(127): call_user_func_array()
#7 /home/wordpress/public_html/web/wp/wp-includes/class-wp-hook.php(308): WP_Stream\Connector->callback()
#8 /home/wordpress/public_html/web/wp/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
#9 /home/wordpress/public_html/web/wp/wp-includes/plugin.php(517): WP_Hook->do_action()
#10 /home/wordpress/public_html/web/wp/wp-includes/meta.php(334): do_action()
#11 /home/wordpress/public_html/web/wp/wp-includes/post.php(2524): update_metadata()
#12 /home/wordpress/public_html/web/app/plugins/wordpress-seo/inc/class-wpseo-meta.php(717): update_post_meta()
#13 /home/wordpress/public_html/web/app/plugins/wordpress-seo/admin/metabox/class-metabox.php(799): WPSEO_Meta::set_value()
#14 /home/wordpress/public_html/web/wp/wp-includes/class-wp-hook.php(310): WPSEO_Metabox->save_postdata()
#15 /home/wordpress/public_html/web/wp/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
#16 /home/wordpress/public_html/web/wp/wp-includes/plugin.php(517): WP_Hook->do_action()
#17 /home/wordpress/public_html/web/wp/wp-includes/post.php(4726): do_action()
#18 /home/wordpress/public_html/web/wp/wp-includes/post.php(4817): wp_insert_post()
#19 /home/wordpress/public_html/web/wp/wp-admin/includes/post.php(439): wp_update_post()
#20 /home/wordpress/public_html/web/wp/wp-admin/post.php(227): edit_post()
#21 {main}
PHP Version 8.0.29
Same error here: An error of type E_ERROR was caused in line 139 of the file /nas/content/live/THEME/wp-content/plugins/stream/classes/class-log.php. Error message: Uncaught ValueError: Unknown format specifier "Q" in /nas/content/live/THEME/wp-content/plugins/stream/classes/class-log.php:139
Getting the same with Stream 4.0.0, also with a Yoast SEO property.
Input
array(3) {
["meta_key"]=>
string(26) "_yoast_wpseo_content_score"
["meta_value"]=>
string(2) "90"
["post_type"]=>
string(4) "page"
}
Error
Fatal error: Uncaught Error: Unknown format specifier ")"
in /app/web/app/plugins/stream/classes/class-log.php on line 131
Call stack:
vsprintf()
app/plugins/stream/classes/class-log.php:131
The reason seems to be the unescaped % in the string that gets wrongly parsed by vsprintf.
Wow, somebody reported the exact same issue yesterday: https://wordpress.org/support/topic/fatal-error-when-saving-the-seo-title-meta-with-in-the-post-title/
This code might be outdated:
https://github.com/xwp/stream/blob/0336294c11ac185629c4fa66b31d18451fe0fa1d/connectors/class-connector-wordpress-seo.php#L418-L435
I found a quick fix / hot patch with str_replace():
sprintf(
/* translators: %1$s: a meta field title, %2$s: a post title, %3$s: a post type (e.g. "Description", "Hello World", "Post") */
__( 'Updated "%1$s" of "%2$s" %3$s', 'stream' ),
$field['title'],
str_replace('%', '%%', $post->post_title),
$post_type_label
),
I found, that a lot of the other connectors are passing database strings to log() as well, without checking if they contain %. This should be patched for all these occurrences, right?
Related: https://github.com/xwp/stream/issues/1489
Is this fixed by https://github.com/xwp/stream/pull/1508 ?
@krokodok Yes it is! Thank you, I'll close this now.