Closed waviaei closed 3 months ago
Describe the bug
Fatal error due to PHP specification change of mb_strpos since PHP 8.0.
[27-Aug-2024 12:44:20 UTC] PHP Fatal error: Uncaught TypeError: mb_strrpos(): Argument #3 ($offset) must be of type int, string given in /var/web/wp/wp-content/plugins/wp-to-twitter/wpt-truncate.php:205 Stack trace: #0 /var/web/wp/wp-content/plugins/wp-to-twitter/wpt-truncate.php(205): mb_strrpos('#2024\xE5\xB9\xB4\xE7\xA7\x8B\xE5\x8F\xB7 ...', '#', 'UTF-8') #1 /var/web/wp/wp-content/plugins/wp-to-twitter/wp-to-twitter.php(981): jd_truncate_tweet('8/30\xE6\x97\xA5\xE7\x99\xBA\xE5\xA3\xB2\xE3\x81...', Array, 160803) #2 /var/web/wp/wp-content/plugins/wp-to-twitter/wp-to-twitter.php(2037): wpt_tweet(160803, 'instant', Object(WP_Post), true, Object(WP_Post)) #3 /var/web/wp/wp-content/plugins/wp-to-twitter/wp-to-twitter.php(1991): wpt_twit_instant(160803, Object(WP_Post), true, Object(WP_Post)) #4 /var/web/wp/wp-includes/class-wp-hook.php(308): wpt_twit(160803, Object(WP_Post), true, Object(WP_Post)) #5 /var/web/wp/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(160803, Array) #6 /var/web/wp/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #7 /var/web/wp/wp-includes/post.php(5436): do_action('wp_after_insert...', 160803, Object(WP_Post), true, Object(WP_Post)) #8 /var/web/wp/wp-includes/post.php(4729): wp_after_insert_post(Object(WP_Post), true, Object(WP_Post)) #9 /var/web/wp/wp-includes/post.php(4817): wp_insert_post(Array, false, true) #10 /var/web/wp/wp-admin/includes/post.php(439): wp_update_post(Array) #11 /var/web/wp/wp-admin/post.php(227): edit_post() #12 {main} thrown in /var/web/wp/wp-content/plugins/wp-to-twitter/wpt-truncate.php on line 205
Looking at here: https://github.com/joedolson/wp-to-twitter/blob/97ce57f68b379cef9b735da20cecb9aa63ccc131/src/wpt-truncate.php#L205
And where $encoding is substituted here https://github.com/joedolson/wp-to-twitter/blob/97ce57f68b379cef9b735da20cecb9aa63ccc131/src/wpt-truncate.php#L88
$encoding
Therefore it seems to be effected to the change
8.0.0 | Passing the encoding as the third argument instead of an offset has been removed.
To Reproduce
We found this error from the log. Should be able to reproduce using PHP 8+?
Expected behavior
No fatal error.
Thanks, @waviaei!
Hi @joedolson , thank you fro fixing that issue. Do you have ETA for the next release with this fix?
Soon; I've been traveling much of the last couple weeks.
Describe the bug
Fatal error due to PHP specification change of mb_strpos since PHP 8.0.
Looking at here: https://github.com/joedolson/wp-to-twitter/blob/97ce57f68b379cef9b735da20cecb9aa63ccc131/src/wpt-truncate.php#L205
And where
$encoding
is substituted here https://github.com/joedolson/wp-to-twitter/blob/97ce57f68b379cef9b735da20cecb9aa63ccc131/src/wpt-truncate.php#L88Therefore it seems to be effected to the change
To Reproduce
We found this error from the log. Should be able to reproduce using PHP 8+?
Expected behavior
No fatal error.