Guard POSIX UID/GID lookups and fix getGid() implementation#7
Conversation
Guard POSIX UID/GID lookups and fix getGid() implementation Add graceful fallbacks for environments where POSIX functions are unavailable.
|
One small thought after reflecting on the implementation and the production testing: while the current fallback to getmyuid() / getmygid() is more defensive and supports environments where those functions are available but the POSIX extension is not, another possible approach would be to simplify the implementation to only guard the posix_*() calls and return 0 if they are unavailable. I chose the more defensive implementation because it preserves additional functionality where possible, but if you'd prefer the simpler approach for consistency or maintainability, I'd be happy to update the PR accordingly. |
|
Thank you for the patch. Since the dependency of the Flysystem Drupal module (which is the only reason this library exists) on this library has been written out of version 3.0.x as of late last month, I think we can keep this patch as it (I’ve tested and verified that it is working). My expectation is that versions 2.2 and 2.3 will be deprecated once Drupal 12 is released, unless some of the other module maintainers want to continue supporting those versions. My focus will be on supporting 3.0.x going forward. |
Fixes #6
This PR:
posix_getuid()posix_getgid()getmyuid()/getmygid()0if neither function existsgetGid()incorrectly callingposix_getuid()This change was validated during a production Drupal 11.4 migration from S3FS to Flysystem.
The issue was observed under PHP-FPM where POSIX functions were unavailable, resulting in HTTP 500 errors until the guard logic was added.