[buddypress-trac] [BuddyPress Trac] #9307: closedir() should be called conditionally

buddypress-trac noreply at wordpress.org
Tue Sep 30 11:48:24 UTC 2025


#9307: closedir() should be called conditionally
--------------------------+-----------------------------
 Reporter:  GaryJ         |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Core          |    Version:
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 BuddyPress 14.3.4 has a PHP 8 compatibility bug where `closedir()` is
 called outside the conditional block that checks if `opendir()` succeeded.
 This causes fatal errors on platforms that intentionally return empty
 strings for avatar directories (e.g. WPVIP's file service).

 In two places in BuddyPress, `closedir()` is called unconditionally:

 - Line 571 in `bp_core_fetch_avatar()`
 - Line 865 in `bp_core_delete_existing_avatar()`

 This generates a noisy set of PHP warnings that can't be worked around
 with filters, and only a patch being applied to BuddyPress works. If the
 `closedir()` called was inside the conditional that uses `opendir()`, then
 the same intended behaviour would still work, but without the warning from
 PHP 8.

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/9307>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list