[buddypress-trac] [BuddyPress Trac] #9234: PHP Critical Error - Normalize PHP function in bp-xprofile-filters.php
buddypress-trac
noreply at wordpress.org
Mon Sep 16 19:08:27 UTC 2024
#9234: PHP Critical Error - Normalize PHP function in bp-xprofile-filters.php
--------------------------+-----------------------------
Reporter: johnamp | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Core | Version: 14.1.0
Severity: normal | Keywords:
--------------------------+-----------------------------
I am working with a client that is using Buddyboss 2.6.90, Memberium,
Woocommerce, Learndash, wordfence as their required plugins.
I know this is the Buddypress site but I don't have a client login to
Buddyboss to submit a ticket and this may be applicabile to both???
All other plugins removed. Buddypress child theme. All plugins and themes
updated to latest. PHP version 8.2.23. Apache server VPN.
Does occur with WP default theme.
It occurs if Wordfence deactivated.
It occurs if Learndash deacticated.
It occurs if Woocommerce is deactivated.
I can't run test if Memberium is deactived.
Login to WordPress as Admin.
When going to WordPress -> Users -> hightlight a USER and "View As.."
appears, if I click on this option I get this critical error:
[16-Sep-2024 17:44:23 UTC] PHP Fatal error: Uncaught ValueError:
Normalizer::normalize(): Argument #2 ($form) must be a a valid
normalization form in /var/www/vhosts/********.app/learning.********.app
/wp-content/plugins/buddyboss-platform/bp-xprofile/bp-xprofile-
filters.php:948
Stack trace:
#0 /var/www/vhosts/********.app/learning.********.app/wp-content/plugins
/buddyboss-platform/bp-xprofile/bp-xprofile-filters.php(948):
Normalizer::normalize()
#1 /var/www/vhosts/********.app/learning.********.app/wp-content/plugins
/buddyboss-platform/bp-xprofile/bp-xprofile-functions.php(2003):
bp_xprofile_validate_nickname_value()
#2 /var/www/vhosts/********.app/learning.********.app/wp-content/plugins
/buddyboss-platform/bp-xprofile/bp-xprofile-filters.php(826):
bp_xprofile_get_member_display_name()
#3 /var/www/vhosts/********.app/learning.********.app/wp-includes/class-
wp-hook.php(324): xprofile_filter_get_user_display_name()
#4 /var/www/vhosts/********.app/learning.********.app/wp-
includes/plugin.php(205): WP_Hook->apply_filters()
#5 /var/www/vhosts/********.app/learning.********.app/wp-content/plugins
/buddyboss-platform/bp-members/bp-members-functions.php(585):
apply_filters()
#6 /var/www/vhosts/********.app/learning.********.app/wp-content/plugins
/buddyboss-platform/bp-core/bp-core-template.php(3500):
bp_core_get_user_displayname()
#7 /var/www/vhosts/********.app/learning.********.app/wp-content/plugins
/buddyboss-platform/bp-core/bp-core-filters.php(683): bp_get_title_parts()
#8 /var/www/vhosts/********.app/learning.********.app/wp-includes/class-
wp-hook.php(324): bp_modify_document_title_parts()
#9 /var/www/vhosts/********.app/learning.********.app/wp-
includes/plugin.php(205): WP_Hook->apply_filters()
#10 /var/www/vhosts/********.app/learning.********.app/wp-includes
/general-template.php(1283): apply_filters()
#11 /var/www/vhosts/********.app/learning.********.app/wp-includes
/general-template.php(1312): wp_get_document_title()
#12 /var/www/vhosts/********.app/learning.********.app/wp-includes/class-
wp-hook.php(324): _wp_render_title_tag()
#13 /var/www/vhosts/********.app/learning.********.app/wp-includes/class-
wp-hook.php(348): WP_Hook->apply_filters()
#14 /var/www/vhosts/********.app/learning.********.app/wp-
includes/plugin.php(517): WP_Hook->do_action()
#15 /var/www/vhosts/********.app/learning.********.app/wp-includes
/general-template.php(3065): do_action()
#16 /var/www/vhosts/********.app/learning.********.app/wp-content/themes
/buddyboss-theme/header.php(17): wp_head()
#17 /var/www/vhosts/********.app/learning.********.app/wp-
includes/template.php(810): require_once('...')
#18 /var/www/vhosts/********.app/learning.********.app/wp-
includes/template.php(745): load_template()
#19 /var/www/vhosts/********.app/learning.********.app/wp-includes
/general-template.php(48): locate_template()
#20 /var/www/vhosts/********.app/learning.********.app/wp-content/themes
/buddyboss-theme/buddypress.php(10): get_header()
#21 /var/www/vhosts/********.app/learning.********.app/wp-includes
/template-loader.php(106): include('...')
#22 /var/www/vhosts/********.app/learning.********.app/wp-blog-
header.php(19): require_once('...')
#23 /var/www/vhosts/********.app/learning.********.app/index.php(17):
require('...')
#24 {main}
thrown in /var/www/vhosts/********.app/learning.********.app/wp-
content/plugins/buddyboss-platform/bp-xprofile/bp-xprofile-filters.php on
line 948
The PHP code for the Normalize Error is below (on of 3 instances on the
bp-xprofile-filters.php file):
{{{#!php
<?php
/**
* Validate First Name and Last Name with Maximum Length.
*
* @since BuddyBoss 2.6.40
*
* @param string $retval Return value of the field.
* @param int $field_id Field id.
* @param string $value Field value.
*
* @return mixed|string
*/
function bb_xprofile_validate_character_limit_value( $retval, $field_id,
$value ) {
if ( ! in_array( (int) $field_id, array(
bp_xprofile_firstname_field_id(), bp_xprofile_lastname_field_id() ), true
) ) {
return $retval;
}
$value = strtolower( $value );
if ( class_exists( 'Normalizer' ) ) {
// Ensures that the combined characters are treated as a
single character.
$value = Normalizer::normalize( $value, 16 );
}
$field_name = xprofile_get_field( $field_id )->name;
// Must be shorter than 32 characters.
$field_length = (int) apply_filters(
'bb_xprofile_field_character_max_length', 32 );
$value_length = function_exists( 'mb_strlen' ) ? mb_strlen( $value
) : strlen( $value );
if ( $value_length > $field_length ) {
return sprintf(
/* translators: 1. Field Name, 2. character
length. */
__( '%1$s must be shorter than %2$d characters.',
'buddyboss' ),
$field_name,
$field_length
);
}
return $retval;
}
}}}
If I comment out the **$value = Normalizer::normalize( $value, 16 );**
above ( all 3 instances) or change it to **$value = Normalizer::normalize(
$value, Normalizer::FORM_C );** I do not get the error and the view is
switched to that user chosen.
If I return the 3 instances back to **$value = Normalizer::normalize(
$value, 16 );** I get the fatal error again.
When I check the Apache settings for the PHP ITNL attribute, there is none
available. Looking into this, I read that the INTL (International
Normalize) functions are now built into PHP8. We restarted the server just
in case and still got the error. Made the above changes and do not get
this error.
At the moment I am going to leave the buddyboss filter file with this
change in our wordpress installation.
Is this anything else I would need to check or do to make the server
compatible with the ($value, 16)?
When I look up the Normalize in the PHP Manual I don't see "16" or any
other number as an option for the 2nd attribute. I seem to recall
something like this in Python but not in PHP. PHP manual notes these as an
option:
Normalizer::NFD;
Normalizer::NFKD;
Normalizer::NFC;
Normalizer::NFKC;
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/9234>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list