Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #5025: Type error when sending a PM without the attachment field #5027

Merged
merged 1 commit into from Jul 10, 2023

Conversation

Deltik
Copy link
Member

@Deltik Deltik commented Jul 1, 2023

Motivation and Context

There is a bug where the pm plugin would return fatally error in PHP 8.2 if the user doesn't have permission to add an attachment when sending a private message. This error is due to the fact that the code expects $_FILES['file_userfile'] to be an array, but this array will not be present if the user doesn't have permission to add an attachment.

Fixes #5025

Description

This change adds a check before trying to iterate through $_FILES['file_userfile'], ensuring that it is an array before processing the attachment. If this is not an array, then no actions will be taken on $_FILES['file_userfile'], which avoids the TypeError.

How Has This Been Tested?

The fix was manually tested in a local development environment with PHP 8.2 by sending PMs with and without the attachment permission.

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (a change to man pages or other documentation)

Checklist

@codeclimate
Copy link

codeclimate bot commented Jul 1, 2023

Code Climate has analyzed commit 5196c4f and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 0.0% (80% is the threshold).

This pull request will bring the total coverage in the repository to 34.5% (-0.2% change).

View more on Code Climate.

@CaMer0n
Copy link
Member

CaMer0n commented Jul 10, 2023

Thank you @Deltik !

@CaMer0n CaMer0n merged commit e615bcf into e107inc:master Jul 10, 2023
199 of 200 checks passed
@Deltik Deltik deleted the fix/5025 branch July 10, 2023 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PM plugin - fatal error if user is not allowed to add attachment
2 participants