Skip to content

Commit

Permalink
[BUGFIX] Fix ext_config_template.txt zero-based category ordering
Browse files Browse the repository at this point in the history
In the Admin Tools > Settings > Extension Configuration module,
extensions can provide a ext_config_template.txt file.

Comments inside that file dictate where and in which order a
configuration option is listed.

The syntax is:

```
 # cat=SomeCategory//0; type=boolean; label=some config
bar = 0

 # cat=SomeCategory//1; type=boolean; label=other config
baz = 0
```

The parsing routine however could not properly deal with
"0" entries for the input element order because checking
this was using an "falsy" statement instead of allowing
also "0" as a string. In this case, such a zero-based
config element was not displayed.

This is fixed, and an example is added to the EXT:styleguide
extension configuration.

Note that the error would not cause problems when either:

* Another category assignment of another input element
took place before, thus properly initializing
the sort ordering.

* The key did not use "0" as a sorting index, but anything
non-falsy.

* The string "cat=SomeCategory//0" was replaced with
"cat=SomeCategory/0" (thus having an unset sorting key).

Resolves: #102760
Related: #97816
Releases: main, 12.4
Change-Id: I6954bcf8f840d9e45372fc8fa8099381ce2b8b76
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84912
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
  • Loading branch information
fe-hicking authored and lolli42 committed Jun 30, 2024
1 parent 6057cf1 commit 18627cf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Classes/TypoScript/AST/Visitor/AstConstantCommentVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ private function parseNodeComment(TokenStreamInterface $commentTokenStream, stri
$sortIdentifier = empty($subCategoryOrder) ? $this->subCategoryCounter : $subCategoryOrder;
$parsedCommentArray['subcat_sorting_first'] = $this->subCategories[$subCategory]['sorting'];
$parsedCommentArray['subcat_sorting_second'] = $sortIdentifier . 'z';
} elseif ($subCategoryOrder) {
} elseif ($subCategoryOrder !== '') {
// "0" is a valid key for an assignment like "# cat=foo//0; type=boolean; label=some config"
$parsedCommentArray['subcat_name'] = 'other';
$parsedCommentArray['subcat_label'] = 'Other';
$parsedCommentArray['subcat_sorting_first'] = 'o';
Expand Down

0 comments on commit 18627cf

Please sign in to comment.