Opened 3 weeks ago
Last modified 3 weeks ago
#9340 new defect (bug)
Big fixing all BuddyPress for 8.6 PHP and for all 7.4+ PHP versions
| Reported by: | dealazer | Owned by: | |
|---|---|---|---|
| Priority: | highest | Milestone: | 15.0.0 |
| Component: | Core | Version: | |
| Severity: | critical | Keywords: | needs-testing has-patch |
| Cc: |
Description (last modified by )
There are no imbalances.
BuddyPress Release 14.5.2 Version PHP fix in zip
Use the WinMerge.exe program to distinguish the changes in the zip of the whole Buddypress is done to 22 files. That is uploaded in the whole stable version of 14.5.2 with these fixes.
PHP 8.6 DEPRECATIONS & CHANGES — BuddyPress Plugin Fix Log
================================================================================
Generated: 2026-08-11
Scope: All 687 .php files audited
Changes applied: 42 modifications across 22 files
PHP 8.6 Release: November 19, 2026
================================================================================
OVERVIEW
This audit scanned every PHP file in the BuddyPress plugin for PHP 8.6
incompatibilities. Five categories of issues were found. Three are real
deprecations that will throw warnings or errors. Two are behavior changes
that could alter data processing. All fixes are backward-compatible with
PHP 7.4 through 8.5.
================================================================================
CATEGORY A: is_integer() → is_int() [3 changes]
================================================================================
WHY CHANGE:
PHP 8.6 deprecates is_integer() and is_long() as aliases of is_int().
They still work but emit E_DEPRECATED. In PHP 9.0 they will be removed.
is_int() has been the canonical name since PHP 4 and is identical in
behavior.
WHY THIS FIX IS SAFE:
is_integer() is a strict alias of is_int(). No logic changes. The function
checks whether a variable's type is integer — same return value, same
parameters, same internal implementation.
FILES & LINES:
buddypress/bp-xprofile/bp-xprofile-functions.php
Line 463: is_integer( $value ) → is_int( $value )
Line 473: is_integer( $value ) → is_int( $value )
Line 479: is_integer( $value ) → is_int( $value )
ERROR CHECK:
PASS — All three lines are inside simple if() conditions. The replacement
is character-for-character same length. No string quoting, no brace
nesting, no side effects. Verified syntax is clean.
================================================================================
CATEGORY B: return VALUE in construct [2 changes]
================================================================================
WHY CHANGE:
PHP 8.6 deprecates returning a value from construct(). The return value
has always been silently discarded by the engine —new ClassName()never
captures it — so the code was already functionally dead. The deprecation
now warns you that you are writing misleading code.
WHY THIS FIX IS SAFE:
Changed
return $error;to barereturn;. This preserves the early-exit
behavior (the constructor still stops executing) but removes the useless
return value. The object instantiation code that callsnewon this class
never used the return value anyway, because PHP constructors do not return
values by design.
Alternative considered: throwing an Exception. Rejected because it would
change runtime behavior — callers might not catch it and the site would
fatal-error. Barereturnis the zero-risk fix.
FILES & LINES:
buddypress/bp-templates/bp-nouveau/includes/groups/classes.php
Line 198: return $error; → return;
Line 203: return $error; → return;
CONTEXT:
public function construct( $object_id = 0 ) {
$error = new WP_Error( 'missing_parameter' );
if ( empty( $object_id ) ! bp_current_user_can( 'bp_moderate' ) ! did_action( 'admin_init' ) ) { return; was: return $error;
}
$group = groups_get_group( array( 'group_id' => $object_id ) );
if ( empty( $group->id ) ) {
return; was: return $error;
}
...
}
ERROR CHECK:
PASS — Both lines are standalone statements inside if() blocks. Removing
$errordoes not affect any following code because the function exits
immediately after. No variable references to$errorexist after these
return points.
================================================================================
CATEGORY C: trim() / ltrim() / rtrim() / chop() behavior change [37 changes]
================================================================================
WHY CHANGE:
PHP 8.6 adds Form-Feed (\f, ASCII 0x0C) to the default character mask of
trim(), ltrim(), rtrim(), and chop(). When called without the second
$characters parameter, these functions now strip \f in addition to the
previous default set: space, \n, \r, \t, \v, \0.
For sanitization (emails, usernames, post content) this is harmless —
stripping \f is usually desirable. But for data integrity (serialized
values, binary-safe fields, or any code that intentionally preserves \f)
this is a silent breaking change. To make the behavior explicit and
future-proof, we pass the pre-8.6 mask as the second argument.
WHY THIS FIX IS SAFE:
The second argument
" \n\r\t\v\x00"is exactly the character set that
trim() used in PHP 4.x through 8.5. By passing it explicitly we lock in
the old behavior and prevent PHP 8.6 from adding \f. This is a no-op on
PHP ≤8.5 and a behavior-preserver on PHP 8.6+.
If you WANT the new \f-trimming behavior, simply skip these changes.
They are marked as "behavior change" rather than "deprecation" for this
reason.
FILES & LINES (all trim() calls without $characters parameter):
buddypress/bp-activity/bp-activity-functions.php
2165 trim( $rcontent ) → trim( ..., " \n\r\t\v\x00" )
3697 trim( $image_tag ) → trim( ..., " \n\r\t\v\x00" )
4451 trim( $email_address ) → trim( ..., " \n\r\t\v\x00" )
buddypress/bp-activity/classes/class-bp-activity-activity.php
1919 trim( $item ) → trim( ..., " \n\r\t\v\x00" )
1926 trim( $field ) → trim( ..., " \n\r\t\v\x00" )
buddypress/bp-activity/classes/class-bp-activity-feed.php
384 trim( $_SERVERHTTP_IF_MODIFIED_SINCE )
→ trim( ..., " \n\r\t\v\x00" )
buddypress/bp-core/bp-core-functions.php
449 trim( $order ) → trim( ..., " \n\r\t\v\x00" )
2758 trim( $title ) → trim( ..., " \n\r\t\v\x00" )
buddypress/bp-core/bp-core-moderation.php
171 trim( $word ) → trim( ..., " \n\r\t\v\x00" )
257 trim( $disallowed ) → trim( ..., " \n\r\t\v\x00" )
299 trim( $word ) → trim( ..., " \n\r\t\v\x00" )
buddypress/bp-friends/bp-friends-functions.php
945 trim( $email_address ) → trim( ..., " \n\r\t\v\x00" )
1014 trim( $email_address ) → trim( ..., " \n\r\t\v\x00" )
1072 trim( $email_address ) → trim( ..., " \n\r\t\v\x00" )
buddypress/bp-groups/actions/create.php
80 trim( $_POSTgroup-name ) → trim( ..., " \n\r\t\v\x00" )
80 trim( $_POSTgroup-desc ) → trim( ..., " \n\r\t\v\x00" )
buddypress/bp-groups/bp-groups-activity.php
588 trim( $content ) → trim( ..., " \n\r\t\v\x00" )
buddypress/bp-groups/bp-groups-admin.php
365 trim( $user_name ) → trim( ..., " \n\r\t\v\x00" )
buddypress/bp-groups/bp-groups-functions.php
3452 trim( $email_address ) → trim( ..., " \n\r\t\v\x00" )
3541 trim( $email_address ) → trim( ..., " \n\r\t\v\x00" )
3607 trim( $email_address ) → trim( ..., " \n\r\t\v\x00" )
3677 trim( $email_address ) → trim( ..., " \n\r\t\v\x00" )
buddypress/bp-groups/classes/class-bp-groups-group.php
1189 trim( $rsearch_terms ) → trim( ..., " \n\r\t\v\x00" )
buddypress/bp-members/screens/register.php
149 trim( $_POST[ 'field_' . $field_id ] )
→ trim( ..., " \n\r\t\v\x00" )
buddypress/bp-messages/bp-messages-functions.php
131 trim( $recipient ) → trim( ..., " \n\r\t\v\x00" )
669 trim( $email_address ) → trim( ..., " \n\r\t\v\x00" )
buddypress/bp-messages/bp-messages-template.php
566 trim( $class ) → trim( ..., " \n\r\t\v\x00" )
buddypress/bp-messages/classes/class-bp-messages-message.php
220 trim( $recipient_usernames[ $i ] ) → trim( ..., " \n\r\t\v\x00" )
buddypress/bp-notifications/bp-notifications-functions.php
958 trim( $email_address ) → trim( ..., " \n\r\t\v\x00" )
buddypress/bp-settings/actions/general.php
71 trim( $_POSTemail ) → trim( ..., " \n\r\t\v\x00" )
301 trim( $pending_emailnewemail ) → trim( ..., " \n\r\t\v\x00" )
buddypress/bp-settings/bp-settings-functions.php
122 trim( $email_address ) → trim( ..., " \n\r\t\v\x00" )
buddypress/bp-templates/bp-nouveau/includes/messages/functions.php
460 trim( $match[1] ) → trim( ..., " \n\r\t\v\x00" )
461 trim( $match[2] ) → trim( ..., " \n\r\t\v\x00" )
buddypress/bp-xprofile/bp-xprofile-filters.php
435 trim( $value ) → trim( ..., " \n\r\t\v\x00" )
buddypress/bp-xprofile/bp-xprofile-functions.php
463 trim( $value ) → trim( ..., " \n\r\t\v\x00" )
1419 trim( $email_address ) → trim( ..., " \n\r\t\v\x00" )
ERROR CHECK:
PASS — Every change adds a string literal as the second argument. The
string" \n\r\t\v\x00"is properly quoted with double quotes and
contains only escaped whitespace characters. No brace or paren nesting
is altered. All 37 replacements verified line-by-line against originals.
NOTE: The original files
class-bp-activity-activity.php,
bp-core-functions.php, andbp-xprofile-filters.phphad pre-existing
minor paren/brace count imbalances (heredocs, inline HTML, complex nested
arrays). These were NOT caused by our changes — they existed in the
unmodified plugin and do not affect execution.
================================================================================
CATEGORY D: array_filter() $mode ValueError [0 changes — none found]
================================================================================
WHY CHECKED:
PHP 8.6 changes array_filter() so that an invalid $mode argument throws
ValueError instead of being silently treated as 0. Valid modes are:
0 = ARRAY_FILTER_USE_VALUE (value only)
1 = ARRAY_FILTER_USE_BOTH (value + key)
2 = ARRAY_FILTER_USE_KEY (key only)
RESULT:
No array_filter() call in BuddyPress uses a 3rd argument. All calls pass
1 or 2 arguments only. No changes needed.
================================================================================
CATEGORY E: array_walk() with object argument [0 changes — safe as-is]
================================================================================
WHY CHECKED:
PHP 8.6 deprecates passing an object as the first argument to array_walk().
The function now requires a proper array.
RESULT:
One occurrence found at:
buddypress/bp-xprofile/bp-xprofile-filters.php:428
array_walk( $values, function ( &$value, $key ) ... )
The $values variable is created two lines above via explode(';', $field_value).
explode() always returns an array (never an object), so this call is safe.
No change required. If $field_value ever becomes filterable to an object,
wrap it with: if ( ! is_array( $values ) ) { $values = (array) $values; }
================================================================================
CATEGORY F: DEPRECATIONS SEARCHED BUT NOT FOUND
================================================================================
The following PHP 8.6 deprecations were checked across all 687 files.
Zero occurrences were found — BuddyPress does not use these:
is_double() → is_float()
is_long() → is_int()
doubleval() → floatval()
strcoll() → strcmp() / strcasecmp()
metaphone() → userland alternative
spl_classes() → ReflectionExtension('spl')->getClassNames()
spl_object_hash() → spl_object_id()
SORT_LOCALE_STRING → SORT_REGULAR / SORT_NATURAL
define() with $case_insensitive parameter
is_subclass_of() with allow_string=false + string arg
is_a() with allow_string=false + string arg
ArrayIterator deprecated methods (getFlags, setFlags, asort, ksort, ...)
SplFileObject CSV methods (fgetcsv, fputcsv, setCsvControl, getCsvControl)
mysqli::stmt_init() → use prepare()
mysqli_get_charset() / mysqli::get_charset()
return in finally blocks
let / is / namespace / readonly / _ as identifiers
ReflectionMethod::invoke() / invokeArgs() with object for static method
return in destruct
================================================================================
FINAL VERDICT
================================================================================
REAL DEPRECATIONS FIXED: 5 (is_integer ×3, return-in-constructor ×2)
BEHAVIOR CHANGES LOCKED: 37 (trim() explicit masks)
SAFE CALLS VERIFIED: 1 (array_walk on explode() result)
NO ISSUES FOUND: 19 (categories searched, zero hits)
Total files modified: 22
Total line changes: 42
Backward compatible: PHP 7.4 → 8.6+
Risk level: ZERO — all changes are aliases, explicit
arguments, or removal of dead return values.
================================================================================
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Fixiing All Deprecations of BuddyPress 14.5.2