Skip to:
Content

BuddyPress.org

Opened 6 weeks ago

Closed 4 weeks ago

#9307 closed defect (bug) (fixed)

closedir() should be called conditionally

Reported by: garyj's profile GaryJ Owned by: johnjamesjacoby's profile johnjamesjacoby
Milestone: 15.0.0 Priority: normal
Severity: normal Version:
Component: Core Keywords: commit
Cc: emaralive, GaryJ

Description

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.

Change History (5)

#1 @emaralive
6 weeks ago

  • Cc emaralive added

#2 @GaryJ
6 weeks ago

  • Cc GaryJ added

See this change for BuddyBoss which tackles the same issue.

#3 @espellcaste
6 weeks ago

  • Milestone changed from Awaiting Review to Under Consideration
  • Owner set to espellcaste
  • Status changed from new to assigned

I can handle this. Thanks for the bug report and the prior art.

#4 @johnjamesjacoby
4 weeks ago

  • Keywords commit added
  • Milestone changed from Under Consideration to 15.0.0
  • Owner changed from espellcaste to johnjamesjacoby

#5 @johnjamesjacoby
4 weeks ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 14140:

Core: improve PHP8 compatibility by only calling closedir() on proper opendir() resources.

The intent of this change is to avoid closedir() producing warnings & errors when opendir() had previously returned false.

It also adds a missing closedir() call to the bp_attachments_cover_image_generate_file() function.

Props GaryJ.

Fixes #9307.

Note: See TracTickets for help on using tickets.