Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer-require-checker.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"runLocally",
"set",
"task",
"test"
"test",
"has"
]
}
1 change: 1 addition & 0 deletions deployer/typo3/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
require_once($vendorRoot . '/vendor/move-elevator/deployer-tools/deployer/typo3/task/deploy_cache.php');
require_once($vendorRoot . '/vendor/move-elevator/deployer-tools/deployer/typo3/task/deploy_database.php');
require_once($vendorRoot . '/vendor/move-elevator/deployer-tools/deployer/typo3/task/deploy_setup.php');
require_once($vendorRoot . '/vendor/move-elevator/deployer-tools/deployer/typo3/task/cache_warmup.php');
13 changes: 13 additions & 0 deletions deployer/typo3/task/cache_warmup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Deployer;

// cache warmup
task('cache:warmup', function () {
$siteConfig = has('site_config') ? get('site_config') : 'main';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider validating site_config parameter.

The site config parameter should be validated or escaped to prevent potential command injection issues.

-    $siteConfig = has('site_config') ? get('site_config') : 'main';
+    $siteConfig = has('site_config') ? escapeshellarg(get('site_config')) : 'main';
🤖 Prompt for AI Agents
In deployer/typo3/task/cache_warmup.php at line 7, the site_config parameter is
assigned without validation, which risks command injection. Add validation or
sanitization to ensure the site_config value only contains expected safe
characters or matches allowed values before using it. This prevents malicious
input from being executed in commands.

$activeDir = test('[ -e {{deploy_path}}/release ]') ?
get('deploy_path') . '/release' :
get('deploy_path') . '/current';
runExtended('cd ' . $activeDir . ' && {{bin/php}} {{bin/typo3cms}} warming:cachewarmup -s ' . $siteConfig);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add validation for the typo3-warming extension dependency.

The task uses the warming:cachewarmup command which requires the EXT:typo3-warming extension. Consider adding a check to ensure this extension is available before attempting to run the command.

-    runExtended('cd ' . $activeDir . ' && {{bin/php}} {{bin/typo3cms}} warming:cachewarmup -s ' . $siteConfig);
+    // Check if typo3-warming extension is available
+    $extensionCheck = runExtended('cd ' . $activeDir . ' && {{bin/php}} {{bin/typo3cms}} extension:list --raw | grep -q "^warming"', ['no_throw' => true]);
+    if ($extensionCheck === '') {
+        throw new \Exception('EXT:typo3-warming extension is required for cache warmup but not found.');
+    }
+    runExtended('cd ' . $activeDir . ' && {{bin/php}} {{bin/typo3cms}} warming:cachewarmup -s ' . $siteConfig);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
runExtended('cd ' . $activeDir . ' && {{bin/php}} {{bin/typo3cms}} warming:cachewarmup -s ' . $siteConfig);
// Check if typo3-warming extension is available
$extensionCheck = runExtended(
'cd ' . $activeDir . ' && {{bin/php}} {{bin/typo3cms}} extension:list --raw | grep -q "^warming"',
['no_throw' => true]
);
if ($extensionCheck === '') {
throw new \Exception(
'EXT:typo3-warming extension is required for cache warmup but not found.'
);
}
runExtended(
'cd ' . $activeDir . ' && {{bin/php}} {{bin/typo3cms}} warming:cachewarmup -s ' . $siteConfig
);
🤖 Prompt for AI Agents
In deployer/typo3/task/cache_warmup.php at line 11, add a validation step before
running the warming:cachewarmup command to check if the EXT:typo3-warming
extension is installed and active. Implement a conditional check that verifies
the presence of this extension and only proceeds with the command execution if
the extension is available; otherwise, log an appropriate warning or error
message and skip the command to prevent failures.

});
before('cache:warmup', 'feature:init');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix the hook direction - this runs feature:init before cache:warmup, not after.

The current hook before('cache:warmup', 'feature:init') means "run feature:init before cache:warmup", but according to the AI summary, cache:warmup should run before feature:init.

-before('cache:warmup', 'feature:init');
+before('feature:init', 'cache:warmup');
🤖 Prompt for AI Agents
In deployer/typo3/task/cache_warmup.php at line 13, the hook direction is
reversed; currently, feature:init runs before cache:warmup, but cache:warmup
should run before feature:init. Replace the before() call with
after('feature:init', 'cache:warmup') or adjust the hook so that cache:warmup
executes prior to feature:init as intended.

10 changes: 10 additions & 0 deletions docs/TYPO3.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ dep deploy:cache:clear
dep deploy:cache:warmup
```

> [!NOTE]
> This is just a simple curl request for the public URL configuration of the deployer host.

```bash
dep cache:warmup
```

> [!NOTE]
> This is using the [EXT:typo3-warming](https://github.com/eliashaeussler/typo3-warming) extension to warm up the cache.

### Clearing and warming the cache
Clearing and warming the cache in one combined task

Expand Down