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

PHP Fatal error: Uncaught ValueError w/ Yosat SEO #1443

Closed
thefrosty opened this issue Aug 1, 2023 · 8 comments
Closed

PHP Fatal error: Uncaught ValueError w/ Yosat SEO #1443

thefrosty opened this issue Aug 1, 2023 · 8 comments
Assignees
Labels
Milestone

Comments

@thefrosty
Copy link

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

  1. Add title/content
  2. Update Yoast SEO meta
  3. 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
@Rahe
Copy link

Rahe commented Nov 6, 2023

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

@ariel-integrity
Copy link

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

@krokodok
Copy link

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.

@krokodok
Copy link

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/

@krokodok
Copy link

krokodok commented Jan 16, 2024

This code might be outdated:

$this->log(
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'],
$post->post_title,
$post_type_label
),
array(
'meta_key' => $meta_key,
'meta_value' => $meta_value,
'post_type' => $post->post_type,
),
$object_id,
'wpseo_meta',
'updated'
);
}

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?

@tharsheblows
Copy link
Contributor

Related: #1489

@krokodok
Copy link

Is this fixed by #1508 ?

@tharsheblows
Copy link
Contributor

@krokodok Yes it is! Thank you, I'll close this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants