server
server copied to clipboard
Fix remaining readdir() calls in loops with undesirable false evaluation potential
Summary
Fixes all remaining readdir() calls within loops that had undesirable false evaluation potential (at least in server)
There weren't too many left and the bulk were in tests. The most notable not in tests were these:
copy()in\OC\Files\Storage\CommonisEmpty()inOCA\Files_Trashbin\TrashbincopyRecursive()inOC\Files\Storage\PolyFill\CopyDirectory
Ref: https://www.php.net/manual/en/function.readdir.php
TODO
- [ ] ...
Checklist
- Code is properly formatted
- Sign-off message is added to all commits
- [ ] Tests (unit, integration, api and/or acceptance) are included
- [ ] Screenshots before/after for front-end changes
- [ ] Documentation (manuals or wiki) has been updated or is not required
- [x] Backports requested where applicable (ex: critical bugfixes)
I wonder if these Psaml warnings worth something like:
// Open the directory and obtain a resource handle
$dh = opendir($directory);
// Check if the directory was opened successfully
if (is_resource($dh)) {
// Iterate through directory entries
while (($file = readdir($dh)) !== false) {
// Process each file or directory
}
// Close the directory handle
closedir($dh);
}
🤔
I don't think any of these test fails are related to this PR. 😕
The psalm warnings are likely not new, but silenced before. opendir may return false, which is not what readdir likes.