81261[FEATURE] Deprecate and replace Abstractfile::FILETYPE_* with enum
Commit message
Review
-
Code review CR +2 Done
- Benni Mack +2
- Oliver Klee +1
-
Verified V +2 Done
- Benni Mack +2
- Oliver Klee +1
- core-ci +1 CI
Issues 1
Files 19
- Build/phpstan/phpstan-baseline.neon+0 −5
- typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php+2 −2
- typo3/sysext/core/Classes/Resource/Index/Indexer.php6+4 −27
- typo3/sysext/core/Classes/Resource/Index/MetaDataRepository.php+2 −1
- typo3/sysext/core/Classes/Resource/Processing/LocalPreviewHelper.php+2 −1
- typo3/sysext/core/Classes/Resource/AbstractFile.php10+15 −24
- typo3/sysext/core/Classes/Resource/FileType.phpnew+69 −0
- typo3/sysext/core/Configuration/TCA/pages.php+5 −5
- typo3/sysext/core/Configuration/TCA/sys_file.php+11 −11
- typo3/sysext/core/Configuration/TCA/sys_file_reference.php+5 −5
- typo3/sysext/core/Documentation/Changelog/13.0/Deprecation-102032-AbstractFileConstants.rst14new+53 −0
- typo3/sysext/core/Documentation/Changelog/13.0/Feature-102032-FileType.rst4new+31 −0
- typo3/sysext/core/Tests/Unit/Resource/Index/IndexerTest.php+2 −1
- typo3/sysext/core/Tests/Unit/Resource/Service/ExtractorServiceTest.php+12 −11
- typo3/sysext/filemetadata/Configuration/TCA/Overrides/sys_file_metadata.php+6 −6
- typo3/sysext/filemetadata/Tests/Functional/Tca/FileMetadataVisibleFieldsTest.php18+145 −128
- typo3/sysext/frontend/Configuration/TCA/tt_content.php+10 −10
- typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassConstantMatcher.php+30 −0
- typo3/sysext/seo/Configuration/TCA/Overrides/pages.php+2 −2
Review log 3851
Show 1926 earlier messages
-
Thomas Hohn uploaded patch set 1 09/27/23, 09:31
-
core-ci voted on patch set 1 V -1 09/27/23, 09:46 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47221
-
Thomas Hohn uploaded patch set 2
V -109/27/23, 09:53 -
core-ci voted on patch set 2 V +1 09/27/23, 10:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47223
-
Andreas Kienast commented on patch set 2 CR -1 09/27/23, 12:48
Deprecation-102032-AbstractFileConstants.rst:29How? I think you mean that the extension scanner finds usages.Deprecation-102032-AbstractFileConstants.rst:50`APPLICATION`Deprecation-102032-AbstractFileConstants.rst:52Drop these, please. The main change is in EXT:core only.Deprecation-102032-AbstractFileConstants.rst:52`FullyScanned`, I guess. -
Thomas Hohn uploaded patch set 3
CR -1V +109/27/23, 12:59 -
Thomas Hohn commented on patch set 2 09/27/23, 12:59
AbstractFile.php:291ReplyDoneDeprecation-102032-AbstractFileConstants.rst:29ReplyDoneDeprecation-102032-AbstractFileConstants.rst:50ReplyDoneDeprecation-102032-AbstractFileConstants.rst:52ReplyDoneDeprecation-102032-AbstractFileConstants.rst:52ReplyDone -
core-ci voted on patch set 3 V +1 09/27/23, 13:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47242
-
Oliver Klee commented on patch set 3 V +1 09/27/23, 13:46
Looks very good code-wise! I have commented a few smaller things concerning annotations and tests.AbstractFile.php:106For the `@deprecated` annotations, please also always list when the deprecated thing will be remove, e.g., ", will be removed in TYPO3 14"Indexer.php:322`@return value-of<FileType>` https://phpstan.org/writing-php-code/phpdoc-types#key-and-value-types-of-arrays-and-iterablesFileMetadataVisibleFieldsTest.php:54Instead of having the loop, I'd suggest to use a data provider instead. That would provide these benefits: - you see the labels of the data sets when the tests are run - the other cases in the test are still executed if one of the cases fails (In general, loops in tests are a considered a code smell that indicates that the code structure could be improved.)FileMetadataVisibleFieldsTest.php:55Can we use the positive check instead, i.e., `assertTrue`, so the test is as specific as possible? -
Thomas Hohn uploaded patch set 4
V +109/27/23, 15:36 -
Thomas Hohn commented on patch set 3 09/27/23, 15:36
AbstractFile.php:106ReplyDoneIndexer.php:322ReplyDoneFileMetadataVisibleFieldsTest.php:54ReplyI hope I did it the correct way ;-)FileMetadataVisibleFieldsTest.php:55ReplyDone -
Thomas Hohn commented on patch set 4 09/27/23, 15:36
FileMetadataVisibleFieldsTest.php:54ReplyDone -
core-ci voted on patch set 4 V +1 09/27/23, 15:43 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47255
-
Oliver Klee commented on patch set 4 09/27/23, 16:06
FileMetadataVisibleFieldsTest.php:61`@return array<string, array{0: non-empty-string}` (if you add the labels as proposed below)FileMetadataVisibleFieldsTest.php:83I propose adding labels to the data provider items (using the keys of the outer array), e.g., like this: ```php 'categories' => ['categories'], ``` Then PHPUnit will display the label instead of the numeric ID of the data set that is currently used for the test. -
Thomas Hohn uploaded patch set 5
V +109/28/23, 04:04 -
Thomas Hohn commented on patch set 4 09/28/23, 04:04
FileMetadataVisibleFieldsTest.php:61ReplyDoneFileMetadataVisibleFieldsTest.php:83ReplyDone -
core-ci voted on patch set 5 V -1 09/28/23, 04:16 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47266
-
Thomas Hohn uploaded patch set 6
V -109/28/23, 04:34 -
core-ci voted on patch set 6 V +1 09/28/23, 04:41 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47267
-
Oliver Klee commented on patch set 6 V +1 CR +1 09/28/23, 06:57
Neat! Thanks for this refactoring/cleanup! <3 -
Andreas Kienast commented on patch set 6 CR -1 09/29/23, 07:21
AbstractFile.php:289I propose to use `match()` over `switch`: ``` $this->properties['type'] = match (strtolower($fileType)) { 'text' => FileType::TEXT->value, 'image' => FileType::IMAGE->value, 'audio' => FileType::AUDIO->value, 'video' => FileType::VIDEO->value, 'application', 'software' => FileType::APPLICATION->value, default => FileType::UNKNOWN->value, }; ``` Also, I think it would make sense to return the enum instead (at a later point), but this would be breaking, of course.Indexer.php:327Also here, `match()` over `switch`: ``` $type = match (strtolower($fileType)) { 'text' => FileType::TEXT->value, 'image' => FileType::IMAGE->value, 'audio' => FileType::AUDIO->value, 'video' => FileType::VIDEO->value, 'application', 'software' => FileType::APPLICATION->value, default => FileType::UNKNOWN->value, }; ```Deprecation-102032-AbstractFileConstants.rst:14``` :php:`ìnt` ```Deprecation-102032-AbstractFileConstants.rst:36This sentence is incomplete. Perhaps "[...] are affected."Feature-102032-FileType.rst:23We need an empty line before the list, otherwise the rendered doc is broken.FileMetadataVisibleFieldsTest.php:32Why is this empty?FileMetadataVisibleFieldsTest.php:47This test is now dead. The whole foreach doesn't do anything as the `$this->fileMetadataFields` array is empty.FileMetadataVisibleFieldsTest.php:63Please suffix a data provider with `DataProvider` -
Andreas Kienast commented on patch set 6 09/29/23, 07:22
FileMetadataVisibleFieldsTest.php:63ReplyAlso, the return type declaration is missing. -
Thomas Hohn commented on patch set 6 09/29/23, 08:11
FileMetadataVisibleFieldsTest.php:47ReplySo I would need to fill the $this->fileMetadataFields array again - but hust with the file types and fix the other stuff? -
Thomas Hohn uploaded patch set 7
CR +1V +110/02/23, 13:23 -
Thomas Hohn commented on patch set 7 10/02/23, 13:25
AbstractFile.php:289ReplyDoneIndexer.php:327ReplyDoneDeprecation-102032-AbstractFileConstants.rst:14ReplyDoneDeprecation-102032-AbstractFileConstants.rst:36ReplyDoneFeature-102032-FileType.rst:23ReplyDone -
core-ci voted on patch set 7 V +1 10/02/23, 13:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47350
-
Thomas Hohn uploaded patch set 8
V +110/02/23, 13:58 -
core-ci voted on patch set 8 V +1 10/02/23, 14:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47351
-
Chris Müller commented on patch set 8 10/02/23, 14:45
Feature-102032-FileType.rst:21::php: -> :php: -
Thomas Hohn uploaded patch set 9
V +110/02/23, 19:05 -
Thomas Hohn uploaded patch set 10 10/02/23, 19:11
-
Thomas Hohn commented on patch set 9 10/02/23, 19:11
Feature-102032-FileType.rst:21ReplyDoneFileMetadataVisibleFieldsTest.php:32ReplyRemoved nowFileMetadataVisibleFieldsTest.php:47ReplyDoneFileMetadataVisibleFieldsTest.php:63ReplyDone -
core-ci voted on patch set 9 V +1 10/02/23, 19:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47358
-
Thomas Hohn commented on patch set 10 10/02/23, 19:15
FileMetadataVisibleFieldsTest.php:32ReplyDone -
core-ci voted on patch set 10 V +1 10/02/23, 19:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47359
-
Oliver Klee voted on patch set 10 V +1 CR +1 10/03/23, 15:36
-
Benni Mack commented on patch set 10 10/12/23, 07:30
AbstractFile.php:73what about this property?AbstractFile.php:289can we move this in the Enum?Indexer.php:323I think we should move this method in the Enum. then having a (int)FileType::tryFromMimeType($mimeType) in the code above -
Thomas Hohn uploaded patch set 11
CR +1V +110/12/23, 15:08 -
core-ci voted on patch set 11 V +1 10/12/23, 15:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47724
-
Thomas Hohn commented on patch set 11 10/12/23, 15:31
AbstractFile.php:73ReplyDoneAbstractFile.php:289ReplyDoneIndexer.php:323ReplyDone -
Oliver Klee commented on patch set 12
V +110/12/23, 15:37Published edit on patch set 11. -
Oliver Klee voted on patch set 12 V +1 CR +1 10/12/23, 15:37
-
core-ci voted on patch set 12 V +1 10/12/23, 15:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47725
-
Benni Mack uploaded patch set 13
CR +1V +110/17/23, 19:21 -
Benni Mack voted on patch set 13 V +1 CR +1 10/17/23, 19:22
-
Oliver Klee voted on patch set 13 V +1 CR +1 10/17/23, 19:28
-
core-ci voted on patch set 13 V +1 10/17/23, 19:29 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47882
-
Benni Mack voted on patch set 13 V +2 CR +2 10/17/23, 19:32
-
Benni Mack merged patch set 14 10/17/23, 19:32
-
Benjamin Franzke commented on patch set 14 10/25/24, 06:56
Deprecation-102032-AbstractFileConstants.rst:43Post -1 This change is annoying and half-baked: Replacing a constant by an enum and then using the enum value all over the place neglects the advantages of an enum. Sorry, this should have never been merged in this state. It's an intermediate "solution" with no benefit. TCA should have been adapted (yea that's complicated, but don't change things just to change them, improve them!) to accept the plain enum, not the value. After all, with the current state there is *ZERO* technical benefit in dropping the constant values, as we're using values all over the place anyway. That means extension authors have to change extensions for *ZERO* benefit. Change for the sake of change. -
Benni Mack commented on patch set 14 10/25/24, 08:00
Deprecation-102032-AbstractFileConstants.rst:43ReplyYes. You are right, as I stumbled over this multiple times in the past year. Thanks for mentioning this again. Unfortunately this is now (way) too late, but I will keep this in mind for all future changes in this area.
AbstractFile.php:291