Skip to content

Conversation

@joshtrichards
Copy link
Member

@joshtrichards joshtrichards commented Jan 22, 2026

  • Resolves: #

Summary

Refactor MemoryInfo to leverage PHP's (8.2+) native ini_parse_quantity() for parsing and converting memory_limit values.

  • Eliminates custom logic and unnecessary checks.
  • Fully aligns parsing with PHP's internal parsing behavior.
  • Fixes a bug where our support for float in this particular context was too generous, because on 32-bit systems PHP's own parsing of this value wraps. By switching to this new function we are literally checking from PHP's perspective rather than checking the user's intent. Checking actual effective config value is more appropriate in this context.

Refactor Util::uploadLimit(), maxUploadFilesize(), and related helpers to improve reliability, correctness, and standards alignment.

  • Use PHP's native ini_parse_quantity() for accurate parsing of upload_max_filesize and post_max_size, replacing custom logic and computerFileSize().
  • Normalize both 0 and -1 as unlimited for INI settings, consistently returning -1 instead of INF or 0 for unlimited upload settings.
  • Throw InvalidArgumentException for invalid or unparsable INI values, making misconfigs fail fast instead of silently.
  • Always return the stricter of upload_max_filesize or post_max_size, with clear logic and optional warning on misconfiguration.
  • Update maxUploadFilesize() logic to clearly and robustly combine quota/free space and system limits, supporting unlimited semantics correctly.
  • Improve docblocks for clarity and standards compliance.
  • Remove ambiguous or legacy code paths, reducing edge cases and future bugs.

Refs:

TODO

Checklist

Refactor `MemoryInfo` to leverage PHP's (8.2+) native `ini_parse_quantity()` for parsing and converting `memory_limit` values.

- Eliminates custom logic and unnecessary checks.
- Fully aligns parsing with PHP's internal parsing behavior.
- Fixes a bug where our support for `float` in this particular context was too generous, because on 32-bit systems PHP's own parsing of this value wraps. By switching to this new function we are literally checking from PHP's perspective rather than checking the user's intent. Checking actual effective config value is more appropriate in this context.

Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
@joshtrichards joshtrichards added this to the Nextcloud 33 milestone Jan 22, 2026
@joshtrichards joshtrichards added bug 3. to review Waiting for reviews feature: 32bits Bug specific to 32bits architectures ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring) labels Jan 22, 2026
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
@joshtrichards joshtrichards removed the 3. to review Waiting for reviews label Jan 23, 2026
…r upload limits

Signed-off-by: Josh <josh.t.richards@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug feature: 32bits Bug specific to 32bits architectures ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants