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

Bug: Provide better checks and error reporting if Photo dirs are not writeable #6891

Closed
grayeul opened this issue Feb 22, 2024 · 3 comments · Fixed by #7060
Closed

Bug: Provide better checks and error reporting if Photo dirs are not writeable #6891

grayeul opened this issue Feb 22, 2024 · 3 comments · Fixed by #7060
Assignees
Labels
bug good first issue Indicates a good issue for first-time contributors Photos
Milestone

Comments

@grayeul
Copy link
Contributor

grayeul commented Feb 22, 2024

Description

File permissions are tricky because this code can be run in a number of different environments, as different users, in both development and production mode. Better checks are needed, followed by better error reporting when there are problems with writeable files or directories. This particular issue is to address the problems in the Photo management area, which tries to create/update photos and thumbnails.

  • ChurchCRM version: 5.5.0
  • PHP version the server running: PHP 5.1
  • DB Server and Version the server is running: Mariadb 10.3.39

Steps To Reproduce

The errors are seen if the src/Images/{Person,Family} and 'thumbnails' directory in each of those are not writeable. The errors generated in this case are not obvious.

Expected behavior

Ideally an unwriteable file or directory would generate a meaningful error, at least in the logs, if not on screen.

Screenshots and/or logs

📋 Relevant screenshots:

N/A

📋 Logs:

N/A

Desktop (please complete the following information):

  • OS and Version: RockyLinux 8.9
  • Browser (and Version): Firefox 115.6.0esr (64-bit)
@grayeul grayeul added the bug label Feb 22, 2024
@grayeul grayeul self-assigned this Feb 22, 2024
@DAcodedBEAT DAcodedBEAT added Photos good first issue Indicates a good issue for first-time contributors labels Feb 27, 2024
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Mar 29, 2024
@DAcodedBEAT DAcodedBEAT removed the Stale label Apr 2, 2024
@DAcodedBEAT DAcodedBEAT added this to the vNext (5.8.0) milestone Apr 15, 2024
@respencer
Copy link
Contributor

There is a warning shown in /v2/admin/debug near the bottom of that page:

Screen Shot 2024-04-26 at 16 56 12

private static function testImagesWriteable(): bool
{
return is_writable(SystemURLs::getDocumentRoot() . '/Images/') &&
is_writable(SystemURLs::getDocumentRoot() . '/Images/Family') &&
is_writable(SystemURLs::getDocumentRoot() . '/Images/Person');
}

How exactly would you like it to be handled differently?

@DAcodedBEAT
Copy link
Contributor

There is a warning shown in /v2/admin/debug near the bottom of that page:

Screen Shot 2024-04-26 at 16 56 12

private static function testImagesWriteable(): bool
{
return is_writable(SystemURLs::getDocumentRoot() . '/Images/') &&
is_writable(SystemURLs::getDocumentRoot() . '/Images/Family') &&
is_writable(SystemURLs::getDocumentRoot() . '/Images/Person');
}

How exactly would you like it to be handled differently?

https://github.com/ChurchCRM/CRM/blob/master/src/ChurchCRM/dto/Photo.php#L192-L197 I believe this should check for is_dir and is_writable and if not, emit a log for each error condition

respencer added a commit to respencer/ChurchCRM that referenced this issue May 27, 2024
respencer added a commit to respencer/ChurchCRM that referenced this issue May 28, 2024
respencer added a commit to respencer/ChurchCRM that referenced this issue May 30, 2024
respencer added a commit to respencer/ChurchCRM that referenced this issue Jun 3, 2024
DAcodedBEAT added a commit that referenced this issue Jun 4, 2024
# Description & Issue number it closes 
<!-- Please include a summary of the changes and the related issue.
Please also include relevant motivation and context. -->

Resolves #6891

## Screenshots (if appropriate)
<!-- Before and after --> 

![Screenshot 2024-05-28 at 18-10-56 ChurchCRM
Debug](https://github.com/ChurchCRM/CRM/assets/201834/50e3b83a-7e51-40db-b8e2-7ada0ce3e737)

## How to test the changes?

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

# How Has This Been Tested?

<!-- Please describe the tests that you ran to verify your changes.
Provide instructions so we can reproduce. Please also list any relevant
details for your test configuration -->

# Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue Indicates a good issue for first-time contributors Photos
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants