You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The convert_smilies filter in ACF’s acf_the_content hook causes a fatal error when a count() function is called on a non-countable variable. This happens because convert_smilies attempts to count an array or object that sometimes returns as false. This issue occurs even if convert_smilies is disabled at the theme level.
To Reproduce
Steps to reproduce the behavior:
Add ACF fields with content processed by the acf_the_content filter.
Disable the convert_smilies filter in the theme by adding remove_filter( 'the_content', 'convert_smilies' ); to functions.php.
View any post or page where acf_the_content is called, and observe the PHP fatal error related to count() in convert_smilies.
Expected behavior
ACF should respect the filter removal applied by the theme, or the add_filters function should verify if filters like convert_smilies are already disabled before adding them to acf_the_content. This would prevent fatal errors when filters are already removed or unnecessary.
Error caused:
PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, bool given in /var/www/html/wp-includes/formatting.php:3495
Stack trace:
#0 /var/www/html/wp-includes/class-wp-hook.php(324): convert_smilies()
#1 /var/www/html/wp-includes/plugin.php(205): WP_Hook->apply_filters()
#2 /var/www/html/wp-includes/post-template.php(256): apply_filters()
#3 /var/www/html/wp-content/themes/healingWaves/single.php(116): the_content()
#4 /var/www/html/wp-includes/template-loader.php(106): include('...')
#5 /var/www/html/wp-blog-header.php(19): require_once('...')
#6 /var/www/html/index.php(17): require('...')
#7 {main}
thrown in /var/www/html/wp-includes/formatting.php on line 3495
Screenshots or Video
Not applicable, as the issue results in a fatal error.
function add_filters() {
// Determine the correct image tag filter for compatibility
$wp_filter_content_tags = function_exists('wp_filter_content_tags') ? 'wp_filter_content_tags' : 'wp_make_content_images_responsive';
// Mimic filters added to "the_content" in "wp-includes/default-filters.php"
add_filter('acf_the_content', 'capital_P_dangit', 11);
// Apply wptexturize if it’s available and not disabled in theme settings
if (function_exists('wptexturize') && !has_filter('acf_the_content', 'wptexturize')) {
add_filter('acf_the_content', 'wptexturize');
}
// Conditionally add convert_smilies only if it’s not disabled in theme settings
if (function_exists('convert_smilies') && !has_filter('acf_the_content', 'convert_smilies')) {
add_filter('acf_the_content', 'convert_smilies', 20);
}
// Add wpautop, shortcode_unautop, and other filters with similar checks
if (function_exists('wpautop') && !has_filter('acf_the_content', 'wpautop')) {
add_filter('acf_the_content', 'wpautop');
}
if (function_exists('shortcode_unautop') && !has_filter('acf_the_content', 'shortcode_unautop')) {
add_filter('acf_the_content', 'shortcode_unautop');
}
// Apply the image tag filter if defined
if (!has_filter('acf_the_content', $wp_filter_content_tags)) {
add_filter('acf_the_content', $wp_filter_content_tags);
}
// Add do_shortcode for executing shortcodes in ACF content
if (function_exists('do_shortcode') && !has_filter('acf_the_content', 'do_shortcode')) {
add_filter('acf_the_content', 'do_shortcode', 11);
}
// Embed support checks
if (isset($GLOBALS['wp_embed'])) {
add_filter('acf_the_content', array($GLOBALS['wp_embed'], 'run_shortcode'), 8);
add_filter('acf_the_content', array($GLOBALS['wp_embed'], 'autoembed'), 8);
}
}
Version Information:
WordPress Version: 6.6.2
PHP Version: 8.1.23
ACF Version: ACF PRO 6.3.9
Browser: N/A (server-side error)
Additional context
The convert_smilies filter can cause fatal errors if it’s enabled by ACF but explicitly disabled by the theme, as it attempts to count() a non-countable value. A suggested fix is to add conditional checks in add_filters to respect removed filters and check their availability before adding them to acf_the_content.
The text was updated successfully, but these errors were encountered:
Describe the bug
The convert_smilies filter in ACF’s acf_the_content hook causes a fatal error when a count() function is called on a non-countable variable. This happens because convert_smilies attempts to count an array or object that sometimes returns as false. This issue occurs even if convert_smilies is disabled at the theme level.
To Reproduce
Steps to reproduce the behavior:
Add ACF fields with content processed by the acf_the_content filter.
Disable the convert_smilies filter in the theme by adding remove_filter( 'the_content', 'convert_smilies' ); to functions.php.
View any post or page where acf_the_content is called, and observe the PHP fatal error related to count() in convert_smilies.
Expected behavior
ACF should respect the filter removal applied by the theme, or the add_filters function should verify if filters like convert_smilies are already disabled before adding them to acf_the_content. This would prevent fatal errors when filters are already removed or unnecessary.
Error caused:
Screenshots or Video
Not applicable, as the issue results in a fatal error.
Code
Proposed solution
Version Information:
Additional context
The convert_smilies filter can cause fatal errors if it’s enabled by ACF but explicitly disabled by the theme, as it attempts to count() a non-countable value. A suggested fix is to add conditional checks in add_filters to respect removed filters and check their availability before adding them to acf_the_content.
The text was updated successfully, but these errors were encountered: