Improve support for WP 6.9#2467
Conversation
WalkthroughIntroduces FrmAppHelper::is_valid_utf8($string), delegating to wp_is_valid_utf8 or seems_utf8 when available. Updates FrmXMLHelper::cdata to use the new helper for UTF-8 checks. No other logic or interfaces changed. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as FrmXMLHelper::cdata
participant Helper as FrmAppHelper
participant WP as WordPress Core
Caller->>Helper: is_valid_utf8(str)
alt WP >= 6.9 provides wp_is_valid_utf8
Helper->>WP: wp_is_valid_utf8(str)
WP-->>Helper: bool
else WP has seems_utf8
Helper->>WP: seems_utf8(str)
WP-->>Helper: bool
else No WP validation available
Helper-->>Caller: false
end
Helper-->>Caller: is_valid(bool)
alt not valid UTF-8
Caller->>Caller: utf8_encode(str)
Caller->>Caller: wrap in CDATA
else valid UTF-8 or numeric
Caller->>Caller: wrap/return as existing logic
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 PHPStan (2.1.17)Note: Using configuration file /phpstan.neon. Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
classes/helpers/FrmAppHelper.php (2)
4603-4610: Replace placeholder @SInCE with the actual plugin versionThe docblock still uses a placeholder. Use the plugin's current version (looks like 6.23 from self::$plug_version) or whatever version will ship this change.
- * @since x.x + * @since 6.23
4611-4621: Consider adding a final UTF-8 check fallback (mb_check_encoding) instead of returning falseOn very old WP installs where neither wp_is_valid_utf8 nor seems_utf8 exists (unlikely, but possible), this returns false and forces a conversion attempt downstream. A lightweight safety net is to fall back to mb_check_encoding when available. Also casting to string keeps behavior predictable across scalars.
public static function is_valid_utf8( $string ) { // wp_is_valid_utf8 is added in WP 6.9. if ( function_exists( 'wp_is_valid_utf8' ) ) { - return wp_is_valid_utf8( $string ); + return wp_is_valid_utf8( (string) $string ); } // As of WP 6.9, seems_utf8 is deprecated. if ( function_exists( 'seems_utf8' ) ) { - return seems_utf8( $string ); + return seems_utf8( (string) $string ); } + // Fallback for environments without either function. + if ( function_exists( 'mb_check_encoding' ) ) { + return mb_check_encoding( (string) $string, 'UTF-8' ); + } return false; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
classes/helpers/FrmAppHelper.php(1 hunks)classes/helpers/FrmXMLHelper.php(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
classes/helpers/FrmXMLHelper.php (1)
classes/helpers/FrmAppHelper.php (2)
FrmAppHelper(6-4622)is_valid_utf8(4611-4621)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Cypress
- GitHub Check: PHP 8 tests in WP trunk
- GitHub Check: PHP 7.4 tests in WP trunk
🔇 Additional comments (2)
classes/helpers/FrmXMLHelper.php (2)
1709-1712: Good centralization: use FrmAppHelper::is_valid_utf8 instead of seems_utf8This aligns with WP 6.9 (wp_is_valid_utf8) while retaining backward compatibility via the helper. Logic remains consistent with the previous check.
1709-1712: All directseems_utf8calls are confined toFrmAppHelperThe ripgrep search shows the only remaining call to
seems_utf8lives inclasses/helpers/FrmAppHelper.php(lines 4617–4618), whereis_valid_utf8()falls back to it if available. No other direct uses ofseems_utf8exist in the codebase, so all UTF-8 validations correctly route throughFrmAppHelper::is_valid_utf8.
It looks like the function has a new name in WP 6.9.
This update calls the new function instead of the deprecated one if it is callable.