core
core copied to clipboard
fix: file size in cache is set back to zero if empty content is writt…
…en to a non-empty file
Description
When writing zero length content to a non-empty file the file size in the file cache was not updated.
How Has This Been Tested?
see provided test
Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Database schema changes (next release will require increase of minor version instead of patch)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Technical debt
- [ ] Tests only (no source changes)
Checklist:
- [x] Code changes
- [x] Unit tests added
- [ ] Acceptance tests added
- [ ] Documentation ticket raised:
- [ ] Changelog item, see TEMPLATE
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.
https://drone.owncloud.com/owncloud/core/31293/2/7
make test-php-style
fails.
Only the PHP unit tests on Oracle failed: https://drone.owncloud.com/owncloud/core/31304/19/9
There were 1508 errors:
1) Test\Cache\FileCacheTest::testGarbageCollectOldKeys
Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'UPDATE "oc_filecache" SET "mtime" = NULL, "storage_mtime" = NULL WHERE ("mtime" IS NOT NULL OR "storage_mtime" IS NOT NULL) AND "fileid" = ?' with params [4]:
ORA-01407: cannot update ("AUTOTEST"."oc_filecache"."mtime") to NULL
/drone/src/lib/composer/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php:69
/drone/src/lib/composer/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:182
/drone/src/lib/composer/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:159
/drone/src/lib/composer/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:2212
/drone/src/lib/composer/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:1302
/drone/src/lib/private/DB/Connection.php:191
/drone/src/lib/private/Files/Cache/Cache.php:388
/drone/src/lib/private/Files/Cache/Updater.php:247
/drone/src/lib/private/Files/Cache/Updater.php:160
/drone/src/lib/private/Files/View.php:342
/drone/src/lib/private/Files/View.php:1239
/drone/src/lib/private/Files/View.php:776
/drone/src/lib/public/Events/EventEmitterTrait.php:50
/drone/src/lib/private/Files/View.php:786
/drone/src/lib/private/Cache/File.php:160
/drone/src/tests/lib/Cache/TestCache.php:19
/drone/src/tests/lib/Cache/FileCacheTest.php:91
Caused by
Doctrine\DBAL\Driver\OCI8\OCI8Exception: ORA-01407: cannot update ("AUTOTEST"."oc_filecache"."mtime") to NULL
/drone/src/lib/composer/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php:25
/drone/src/lib/composer/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php:409
/drone/src/lib/composer/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:1290
/drone/src/lib/private/DB/Connection.php:191
/drone/src/lib/private/Files/Cache/Cache.php:388
/drone/src/lib/private/Files/Cache/Updater.php:247
/drone/src/lib/private/Files/Cache/Updater.php:160
/drone/src/lib/private/Files/View.php:342
/drone/src/lib/private/Files/View.php:1239
/drone/src/lib/private/Files/View.php:776
/drone/src/lib/public/Events/EventEmitterTrait.php:50
/drone/src/lib/private/Files/View.php:786
/drone/src/lib/private/Cache/File.php:160
/drone/src/tests/lib/Cache/TestCache.php:19
/drone/src/tests/lib/Cache/FileCacheTest.php:91
2) Test\Cache\FileCacheTest::testGarbageCollectLeaveRecentKeys
Exception: Missing tearDown call in Test\Cache\FileCacheTest
/drone/src/tests/lib/Traits/UserTrait.php:52
/drone/src/tests/lib/TestCase.php:127
/drone/src/tests/lib/Cache/FileCacheTest.php:55
3) Test\Cache\FileCacheTest::testGarbageCollectIgnoreLockedKeys with data set #0 (OCP\Lock\LockedException Object (...))
Exception: Missing tearDown call in Test\Cache\FileCacheTest
/drone/src/tests/lib/Traits/UserTrait.php:52
/drone/src/tests/lib/TestCase.php:127
/drone/src/tests/lib/Cache/FileCacheTest.php:55
...
The first fail might be real?
But then it complains many times about Exception: Missing tearDown call in Test\Cache\FileCacheTest
I restarted CI so we can see if the fail is "variable".
@DeepDiver1975 I used current master and tried overwriting a file with an empty file, then downloading it. The download comes back empty, which is correct. So this problem does not seem to have an externally-observable bad behavior.
Is that correct? This just fixes an internal cache problem?
This just fixes and internal cache problem?
This is a pure PHP API fix from my understanding - it was discovered while working on some other app which used these functions that way ....
:boom: Acceptance tests pipeline apiFederationToRoot1-git-mariadb10.2-php7.4 failed. The build has been cancelled.
https://drone.owncloud.com/owncloud/core/31469/107/1
https://drone.owncloud.com/owncloud/core/31515/36/9 "something happened" (tm) in unit tests with Oracle.
https://drone.owncloud.com/owncloud/core/31515/36/9 "something happened" (tm) in unit tests with Oracle.
:shrug:
looks like I need to fire up oracle locally one more time ....
:boom: Acceptance tests pipeline webUISharingPublic1-chrome-mariadb10.2-php7.4 failed. The build has been cancelled.
https://drone.owncloud.com/owncloud/core/32396/144/1
@DeepDiver1975 merga master or rebase to kick ci again?
:see_no_evil:
There were 5 failures:
1) Test\Files\Cache\UpdaterTest::testMove
Failed asserting that 0 matches expected 1699446390.
/drone/src/tests/lib/Files/Cache/UpdaterTest.php:147
phpvfscomposer:///drone/src/lib/composer/phpunit/phpunit/phpunit:106
2) Test\Files\Cache\UpdaterTest::testMoveNonExistingOverwrite
Failed asserting that 0 matches expected 1699446390.
/drone/src/tests/lib/Files/Cache/UpdaterTest.php:165
phpvfscomposer:///drone/src/lib/composer/phpunit/phpunit/phpunit:106
3) Test\Files\Cache\UpdaterTest::testUpdateStorageMTime
file mtime preserved
Failed asserting that 0 matches expected 1699446390.
/drone/src/tests/lib/Files/Cache/UpdaterTest.php:200
phpvfscomposer:///drone/src/lib/composer/phpunit/phpunit/phpunit:106
4) Test\Files\Cache\UpdaterTest::testMoveCrossStorage
Failed asserting that 0 matches expected 1699446390.
/drone/src/tests/lib/Files/Cache/UpdaterTest.php:246
phpvfscomposer:///drone/src/lib/composer/phpunit/phpunit/phpunit:106
5) Test\Files\Cache\UpdaterTest::testMoveFolderCrossStorage
Failed asserting that 0 matches expected 1699446390.
/drone/src/tests/lib/Files/Cache/UpdaterTest.php:300
phpvfscomposer:///drone/src/lib/composer/phpunit/phpunit/phpunit:106