Skip to content

Commit d679a73

Browse files
authored
Cover legacy conditions (#386)
* [FEATURE] Migrate legacy conditions * ip * hostname * compat version
1 parent 0ad965a commit d679a73

27 files changed

+661
-1
lines changed

packages/typo3-fractor/config/typo3-10.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use a9f\Typo3Fractor\TYPO3v10\Fluid\RemoveNoCacheHashAndUseCacheHashAttributeFluidFractor;
66
use a9f\Typo3Fractor\TYPO3v10\TypoScript\MigrateLegacyTypoScriptConditionsFractor;
7+
use a9f\Typo3Fractor\TYPO3v10\TypoScript\MigrateTypoScriptPageConditionPipeAccessFractor;
78
use a9f\Typo3Fractor\TYPO3v10\TypoScript\RemoveConfigConcatenateJsAndCssFractor;
89
use a9f\Typo3Fractor\TYPO3v10\TypoScript\RemoveConfigDefaultGetVarsFractor;
910
use a9f\Typo3Fractor\TYPO3v10\TypoScript\RemoveConfigHtmlTagDirFractor;
@@ -38,6 +39,7 @@
3839
$services->set(RemoveNoCacheHashAndUseCacheHashAttributeFluidFractor::class);
3940
$services->set(RemoveUseCacheHashFromTypolinkTypoScriptFractor::class);
4041
$services->set(MigrateLegacyTypoScriptConditionsFractor::class);
42+
$services->set(MigrateTypoScriptPageConditionPipeAccessFractor::class);
4143
$services->set(RemoveConfigConcatenateJsAndCssFractor::class);
4244
$services->set(RemoveConfigDefaultGetVarsFractor::class);
4345
$services->set(RemoveConfigHtmlTagDirFractor::class);

packages/typo3-fractor/config/typo3-11.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
declare(strict_types=1);
44

5+
use a9f\Typo3Fractor\TYPO3v11\TypoScript\MigrateTypoScriptPageConditionToTraverseFractor;
56
use a9f\Typo3Fractor\TYPO3v11\TypoScript\RenameFeLoginSettingShowForgotPasswordLinkFractor;
67
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
78

@@ -12,4 +13,5 @@
1213
->autowire();
1314

1415
$services->set(RenameFeLoginSettingShowForgotPasswordLinkFractor::class);
16+
$services->set(MigrateTypoScriptPageConditionToTraverseFractor::class);
1517
};

packages/typo3-fractor/docs/typo3-fractor-rules.md

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 44 Rules Overview
1+
# 46 Rules Overview
22

33
## AbstractMessageGetSeverityFluidFractor
44

@@ -461,6 +461,39 @@ Migrate legacy TypoScript conditions to Symfony expression language syntax
461461

462462
<br>
463463

464+
```diff
465+
-[IP = 123.456.*.*]
466+
+[ip("123.456.*.*")]
467+
page = PAGE
468+
page.10 = TEXT
469+
page.10.value = Visitor IP starts with 123.456
470+
[end]
471+
```
472+
473+
<br>
474+
475+
```diff
476+
-[hostname = example.org]
477+
+[request.getNormalizedParams().getHttpHost() == "example.org"]
478+
page = PAGE
479+
page.10 = TEXT
480+
page.10.value = Visitor hostname is example.org
481+
[end]
482+
```
483+
484+
<br>
485+
486+
```diff
487+
-[compatVersion = 9.5.0]
488+
+[compatVersion("9.5.0")]
489+
page = PAGE
490+
page.10 = TEXT
491+
page.10.value = TYPO3 version is at least 9.5.0
492+
[end]
493+
```
494+
495+
<br>
496+
464497
## MigrateNullFlagFlexFormFractor
465498

466499
Migrate null flag
@@ -711,6 +744,62 @@ Migrate TypoScript loginUser and usergroup conditions (both function-call and eq
711744

712745
<br>
713746

747+
## MigrateTypoScriptPageConditionPipeAccessFractor
748+
749+
Migrate page pipe access in TypoScript conditions to bracket array access syntax
750+
751+
- class: [`a9f\Typo3Fractor\TYPO3v10\TypoScript\MigrateTypoScriptPageConditionPipeAccessFractor`](../rules/TYPO3v10/TypoScript/MigrateTypoScriptPageConditionPipeAccessFractor.php)
752+
753+
```diff
754+
-[page|uid = 2]
755+
+[page["uid"] == 2]
756+
page = PAGE
757+
page.10 = TEXT
758+
page.10.value = Hello
759+
[end]
760+
```
761+
762+
<br>
763+
764+
```diff
765+
-[page|layout == 1]
766+
+[page["layout"] == 1]
767+
page = PAGE
768+
page.10 = TEXT
769+
page.10.value = Layout 1
770+
[end]
771+
```
772+
773+
<br>
774+
775+
## MigrateTypoScriptPageConditionToTraverseFractor
776+
777+
Migrate page["field"] to traverse(page, "field") in TypoScript conditions for safe access
778+
779+
- class: [`a9f\Typo3Fractor\TYPO3v11\TypoScript\MigrateTypoScriptPageConditionToTraverseFractor`](../rules/TYPO3v11/TypoScript/MigrateTypoScriptPageConditionToTraverseFractor.php)
780+
781+
```diff
782+
-[page["uid"] == 1]
783+
+[traverse(page, "uid") == 1]
784+
page = PAGE
785+
page.10 = TEXT
786+
page.10.value = Hello
787+
[end]
788+
```
789+
790+
<br>
791+
792+
```diff
793+
-[page["backend_layout"] == "pagets__home"]
794+
+[traverse(page, "backend_layout") == "pagets__home"]
795+
page = PAGE
796+
page.10 = TEXT
797+
page.10.value = Home layout
798+
[end]
799+
```
800+
801+
<br>
802+
714803
## RemoveConfigDisablePageExternalUrlFractor
715804

716805
Remove config.disablePageExternalUrl
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[IP = 123.456.*.*]
2+
page = PAGE
3+
page.90 = TEXT
4+
page.90.value = IP match
5+
[end]
6+
-----
7+
[ip("123.456.*.*")]
8+
page = PAGE
9+
page.90 = TEXT
10+
page.90.value = IP match
11+
[end]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[IP = 192.168.1.*, 10.0.0.*]
2+
page = PAGE
3+
page.91 = TEXT
4+
page.91.value = local network
5+
[end]
6+
-----
7+
[ip("192.168.1.*") || ip("10.0.0.*")]
8+
page = PAGE
9+
page.91 = TEXT
10+
page.91.value = local network
11+
[end]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[IP = devIP]
2+
page = PAGE
3+
page.92 = TEXT
4+
page.92.value = developer IP
5+
[end]
6+
-----
7+
[ip("devIP")]
8+
page = PAGE
9+
page.92 = TEXT
10+
page.92.value = developer IP
11+
[end]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[hostname = www.example.org]
2+
page = PAGE
3+
page.93 = TEXT
4+
page.93.value = hostname match
5+
[end]
6+
-----
7+
[request.getNormalizedParams().getHttpHost() == "www.example.org"]
8+
page = PAGE
9+
page.93 = TEXT
10+
page.93.value = hostname match
11+
[end]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[hostname = *.example.org]
2+
page = PAGE
3+
page.94 = TEXT
4+
page.94.value = wildcard hostname
5+
[end]
6+
-----
7+
[like(request.getNormalizedParams().getHttpHost(), "*.example.org")]
8+
page = PAGE
9+
page.94 = TEXT
10+
page.94.value = wildcard hostname
11+
[end]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[hostname = www.example.org, login.*.org]
2+
page = PAGE
3+
page.95 = TEXT
4+
page.95.value = multiple hostnames
5+
[end]
6+
-----
7+
[request.getNormalizedParams().getHttpHost() == "www.example.org" || like(request.getNormalizedParams().getHttpHost(), "login.*.org")]
8+
page = PAGE
9+
page.95 = TEXT
10+
page.95.value = multiple hostnames
11+
[end]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[compatVersion = 9.5.0]
2+
page = PAGE
3+
page.96 = TEXT
4+
page.96.value = TYPO3 9.5+
5+
[end]
6+
-----
7+
[compatVersion("9.5.0")]
8+
page = PAGE
9+
page.96 = TEXT
10+
page.96.value = TYPO3 9.5+
11+
[end]

0 commit comments

Comments
 (0)