Skip to:
Content

BuddyPress.org

Opened 11 months ago

Closed 9 months ago

#9307 closed defect (bug) (fixed)

closedir() should be called conditionally

Reported by: GaryJ Owned by: johnjamesjacoby
Priority: normal Milestone: 14.5.0
Component: Media Version:
Severity: normal 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 (9)

#1 @emaralive
11 months ago

  • Cc emaralive added

#2 @GaryJ
11 months ago

  • Cc GaryJ added

See this change for BuddyBoss which tackles the same issue.

#3 @espellcaste
11 months ago

  • Milestone Awaiting ReviewUnder Consideration
  • Owner set to espellcaste
  • Status newassigned

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

#4 @johnjamesjacoby
11 months ago

  • Keywords commit added
  • Milestone Under Consideration15.0.0
  • Owner changed from espellcaste to johnjamesjacoby

#5 @johnjamesjacoby
11 months ago

  • Resolutionfixed
  • Status assignedclosed

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.

#6 @GaryJ
9 months ago

I see some recent changes from other tickets I've opened have been milestoned for 14.5.0. Any chance this one could move from 15.0.0 to 14.5.0 as well please?

This ticket was mentioned in Slack in #buddypress by emaralive. View the logs.


9 months ago

#8 @espellcaste
9 months ago

  • Component CoreMedia
  • Milestone 15.0.014.5.0
  • Resolution fixed
  • Status closedreopened

Sure!

#9 @espellcaste
9 months ago

  • Resolutionfixed
  • Status reopenedclosed

In 14157:

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 (14.0)

Note: See TracTickets for help on using tickets.