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

Uncaught ValueError: Unknown format specifier "!" #1489

Closed
mesiarm opened this issue Jun 24, 2024 · 5 comments · Fixed by #1508
Closed

Uncaught ValueError: Unknown format specifier "!" #1489

mesiarm opened this issue Jun 24, 2024 · 5 comments · Fixed by #1508
Assignees
Labels
Milestone

Comments

@mesiarm
Copy link

mesiarm commented Jun 24, 2024

Bug Report

Expected Behavior

Logging record on post update

Actual Behavior

Got:
Uncaught ValueError: Unknown format specifier "!" in /opt/www/html/wp-content/plugins/stream/classes/class-log.php:127
Stack trace:
#0 /opt/www/html/wp-content/plugins/stream/classes/class-log.php(127): vsprintf()
#1 [internal function]: WP_Stream\Log->log()
#2 /opt/www/html/wp-content/plugins/stream/classes/class-connector.php(178): call_user_func_array()
#3 /opt/www/html/wp-content/plugins/stream/connectors/class-connector-wordpress-seo.php(433): WP_Stream\Connector->log()
#4 /opt/www/html/wp-content/plugins/stream/connectors/class-connector-wordpress-seo.php(353): WP_Stream\Connector_WordPress_SEO->meta()
#5 [internal function]: WP_Stream\Connector_WordPress_SEO->callback_added_post_meta()
#6 /opt/www/html/wp-content/plugins/stream/classes/class-connector.php(127): call_user_func_array()
#7 /opt/www/html/wp-includes/class-wp-hook.php(324): WP_Stream\Connector->callback()
#8 /opt/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#9 /opt/www/html/wp-includes/plugin.php(517): WP_Hook->do_action()
#10 /opt/www/html/wp-includes/meta.php(156): do_action()
#11 /opt/www/html/wp-includes/meta.php(252): add_metadata()
#12 /opt/www/html/wp-includes/post.php(2626): update_metadata()
#13 /opt/www/html/wp-content/plugins/wordpress-seo/inc/class-wpseo-meta.php(717): update_post_meta()
#14 /opt/www/html/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox.php(805): WPSEO_Meta::set_value()
#15 /opt/www/html/wp-includes/class-wp-hook.php(326): WPSEO_Metabox->save_postdata()
#16 /opt/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#17 /opt/www/html/wp-includes/plugin.php(517): WP_Hook->do_action()
#18 /opt/www/html/wp-includes/post.php(4839): do_action()
#19 /opt/www/html/wp-includes/post.php(4930): wp_insert_post()
#20 /opt/www/html/wp-admin/includes/post.php(453): wp_update_post()
#21 /opt/www/html/wp-admin/includes/post.php(2085): edit_post()
#22 /opt/www/html/wp-admin/post.php(336): post_preview()
#23 {main}
thrown

Steps to Reproduce the Problem

  1. Update wp post

Screenshots

Drag and drop screenshots in this area that help illustrate the problem.

System Information

  • Stream plugin version: 4.0.0
  • WordPress version: 6.5.4
  • PHP version: 8.1.2
  • Browser: Chrome
  • Computer operating system: Ubuntu 18.04
@delawski delawski added the bug label Jul 16, 2024
@delawski delawski added this to the 4.0.1 milestone Jul 16, 2024
@tharsheblows
Copy link
Contributor

tharsheblows commented Jul 16, 2024

Support forum issues:
https://wordpress.org/support/topic/fatal-error-unknown-format-specifier-2/
https://wordpress.org/support/topic/fatal-error-when-saving-the-seo-title-meta-with-in-the-post-title/
https://wordpress.org/support/topic/fatal-error-with-php-8-9/
https://wordpress.org/support/topic/your-site-is-experiencing-a-technical-issue-85/

From Fatal Error when saving the SEO title meta with “%” in the post title

I’m facing an issue similar to this https://wordpress.org/support/topic/your-site-is-experiencing-a-technical-issue-85/. I actually managed to reproduce the issue I’m going to mention below in an empty site with just Stream and Yoast SEO (free) installed.

When those two plugins are activated, if a post has the “%” character in its title, and the user is also changing the Yoast SEO title for that post, the attempt to save the Yoast SEO metabox throws a PHP Error

@krokodok
Copy link

krokodok commented Jul 16, 2024

FYI: I have two PRs open for these errors.

#1485
#1486

@tharsheblows
Copy link
Contributor

@krokodok Thank you! I think that's the right approach although I have a request in regards to what you said:

Yes, there is no real consistency in these connectors. But preventing fatal errors seems still necessary with some hot fixes, so that users won't get fatal errors.

Because there's no real consistency, could you add a method to the abstract class Connector like escape_messages( $message ) (or a better name!) which returns the value with the added %? Then use that where necessary.

That way it's easier to discover and document, especially when we go to document how to create new Connectors.

And also add a test of the method to the Test_Connector class. (I wrote a test for the Yoast connector so if you don't want to do that one, I'll add it in later.)

@krokodok
Copy link

@tharsheblows Good feedback! I don't have a lot of time for open source commitments right now, so feel free to take this on if you have some time on your hands.

@tharsheblows
Copy link
Contributor

@krokodok Thank you! I can do that 😊

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.

4 participants