Page MenuHomePhabricator

Make the Files "TTL" API more structured
ClosedPublic

Authored by epriestley on Apr 4 2017, 7:28 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 16, 2:32 AM
Unknown Object (File)
Sat, Apr 13, 8:35 PM
Unknown Object (File)
Sat, Apr 13, 7:32 PM
Unknown Object (File)
Sat, Apr 13, 5:56 PM
Unknown Object (File)
Sat, Apr 13, 1:22 PM
Unknown Object (File)
Sat, Apr 13, 1:22 PM
Unknown Object (File)
Sat, Apr 13, 8:57 AM
Unknown Object (File)
Sat, Apr 13, 8:14 AM
Subscribers

Details

Summary

Ref T11357. When creating a file, callers can currently specify a ttl. However, it isn't unambiguous what you're supposed to pass, and some callers get it wrong.

For example, to mean "this file expires in 60 minutes", you might pass either of these:

  • time() + phutil_units('60 minutes in seconds')
  • phutil_units('60 minutes in seconds')

The former means "60 minutes from now". The latter means "1 AM, January 1, 1970". In practice, because the GC normally runs only once every four hours (at least, until recently), and all the bad TTLs are cases where files are normally accessed immediately, these 1970 TTLs didn't cause any real problems.

Split ttl into ttl.relative and ttl.absolute, and make sure the values are sane. Then correct all callers, and simplify out the time() calls where possible to make switching to PhabricatorTime easier.

Test Plan
  • Generated an SSH keypair.
  • Viewed a changeset.
  • Viewed a raw diff.
  • Viewed a commit's file data.
  • Viewed a temporary file's details, saw expiration date and relative time.
  • Ran unit tests.
  • (Didn't really test Phragment.)

Diff Detail

Repository
rP Phabricator
Branch
files6
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 16291
Build 21656: Run Core Tests
Build 21655: arc lint + arc unit

Unit TestsFailed

TimeTest
95 msPhabricatorAuthInviteTestCase::Unknown Unit Message ("")
Assertion failed, expected values to be equal (at PhabricatorAuthInviteTestCase.php:303): user=out, verified=0, primary=0, should_verify=0, exception=Got unexpected parameters: profile Expected: 'PhabricatorAuthInviteVerifyException' Actual: 'PhutilTypeExtraParametersException'
2 msPhabricatorFileStorageFormatTestCase::Unknown Unit Message ("")
EXCEPTION (PhutilTypeExtraParametersException): Got unexpected parameters: format #0 /core/data/drydock/workingcopy-91/repo/phabricator/src/applications/files/storage/PhabricatorFile.php(1297): PhutilTypeSpec::checkMap(Array, Array) #1 /core/data/drydock/workingcopy-91/repo/phabricator/src/applications/files/storage/PhabricatorFile.php(397): PhabricatorFile->readPropertiesFromParameters(Array)
3 msPhabricatorFileStorageFormatTestCase::Unknown Unit Message ("")
EXCEPTION (PhutilTypeExtraParametersException): Got unexpected parameters: format #0 /core/data/drydock/workingcopy-91/repo/phabricator/src/applications/files/storage/PhabricatorFile.php(1297): PhutilTypeSpec::checkMap(Array, Array) #1 /core/data/drydock/workingcopy-91/repo/phabricator/src/applications/files/storage/PhabricatorFile.php(397): PhabricatorFile->readPropertiesFromParameters(Array)
78 msPhabricatorHandlePoolTestCase::Unknown Unit Message ("")
EXCEPTION (PhutilTypeExtraParametersException): Got unexpected parameters: profile #0 /core/data/drydock/workingcopy-91/repo/phabricator/src/applications/files/storage/PhabricatorFile.php(1297): PhutilTypeSpec::checkMap(Array, Array) #1 /core/data/drydock/workingcopy-91/repo/phabricator/src/applications/files/storage/PhabricatorFile.php(397): PhabricatorFile->readPropertiesFromParameters(Array)
118 msPhabricatorObjectMailReceiverTestCase::Unknown Unit Message ("")
EXCEPTION (PhutilTypeExtraParametersException): Got unexpected parameters: profile #0 /core/data/drydock/workingcopy-91/repo/phabricator/src/applications/files/storage/PhabricatorFile.php(1297): PhutilTypeSpec::checkMap(Array, Array) #1 /core/data/drydock/workingcopy-91/repo/phabricator/src/applications/files/storage/PhabricatorFile.php(397): PhabricatorFile->readPropertiesFromParameters(Array)
View Full Test Results (28 Failed · 323 Passed)

Event Timeline

  • Recognize profile key in parameter dictionary.
  • Also recognize format key in parameter dictionary.
  • Also allow format to accept objects.
This revision is now accepted and ready to land.Apr 4 2017, 9:28 PM
This revision was automatically updated to reflect the committed changes.