Force clone RunTemplates to be created disabled - #7
Conversation
Delegate to the new RunTemplate::cloneAs() (core), which always sets active=false on the clone regardless of the source template's state. Previously the clone copied active verbatim, so cloning an active RunTemplate produced another active one the scheduler could run before its copied config had been reviewed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe runtemplate clone script now delegates cloning to ChangesRuntemplate cloning
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 PHPStan (2.2.7)PHPStan was skipped because the user-provided config is missing the required Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/runtemplateclone.php`:
- Line 41: Update the locked multiflexi-core dependency to a revision that
defines RunTemplate::cloneAs(), then regenerate composer.lock and verify the
updated package is installed before the $sourceTemplate->cloneAs($cloneName)
call in runtemplateclone.php.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: fc27e4ee-4c8e-4278-9caa-14cc03808d35
📒 Files selected for processing (1)
src/runtemplateclone.php
| // Insert new template | ||
| $newId = $newTemplate->insertToSQL($templateData); | ||
| // Clone always comes back disabled, regardless of the source's state | ||
| $newId = $sourceTemplate->cloneAs($cloneName); |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
# Check Composer declarations and the locked core-package revision.
while IFS= read -r manifest; do
echo "== ${manifest} =="
rg -n -C 3 '"vitexsoftware/multiflexi-core"' "${manifest}" || true
done < <(fd -HI -t f '^composer\.(json|lock)$' .)
# Check any available source copy of RunTemplate for cloneAs().
while IFS= read -r file; do
echo "== ${file} =="
rg -n -C 3 'function\s+cloneAs\s*\(' "${file}" || true
done < <(fd -HI -t f 'RunTemplate\.php$' .)Repository: VitexSoftware/multiflexi-web
Length of output: 218
🏁 Script executed:
set -euo pipefail
echo '== Composer manifests =='
git ls-files | grep -E '(^|/)composer\.(json|lock)$' | while IFS= read -r manifest; do
echo "== $manifest =="
grep -n -C 4 'vitexsoftware/multiflexi-core' "$manifest" || true
done
echo '== RunTemplate implementations =='
git ls-files | grep -E '(^|/)RunTemplate\.php$' | while IFS= read -r file; do
echo "== $file =="
grep -n -C 5 -E 'function[[:space:]]+cloneAs[[:space:]]*\(' "$file" || true
done
echo '== Relevant source context =='
if [ -f src/runtemplateclone.php ]; then
nl -ba src/runtemplateclone.php | sed -n '1,100p'
fiRepository: VitexSoftware/multiflexi-web
Length of output: 4277
🏁 Script executed:
set -euo pipefail
python3 - <<'PY'
import json
from pathlib import Path
lock = json.loads(Path("composer.lock").read_text())
for package in lock.get("packages", []) + lock.get("packages-dev", []):
if package.get("name") == "vitexsoftware/multiflexi-core":
print(json.dumps(package, indent=2))
PY
echo '== Upstream refs =='
if command -v curl >/dev/null 2>&1; then
curl -fsSL 'https://api.github.com/repos/VitexSoftware/php-vitexsoftware-multiflexi-core/commits/main' \
| python3 -c 'import json,sys; d=json.load(sys.stdin); print(d.get("sha","")); print(d.get("html_url",""))'
fiRepository: VitexSoftware/multiflexi-web
Length of output: 2865
🏁 Script executed:
set -euo pipefail
repo='VitexSoftware/php-vitexsoftware-multiflexi-core'
sha='80eefa9362998179c5f68374ec5dc77fd605cc57'
for path in \
'src/MultiFlexi/RunTemplate.php' \
'src/MultiFlexi/RunTemplate/RunTemplate.php' \
'src/RunTemplate.php'
do
url="https://raw.githubusercontent.com/${repo}/${sha}/${path}"
echo "== ${path} =="
if curl -fsSL "$url" | tee /tmp/runtemplate-source.php \
| grep -n -C 8 -E 'function[[:space:]]+cloneAs[[:space:]]*\('; then
echo "cloneAs found"
else
status=$?
echo "No cloneAs match or source unavailable (status ${status})"
fi
done
echo '== Candidate paths from upstream tree =='
curl -fsSL "https://github.com/${repo}/tree/${sha}" \
| grep -oE 'href="[^"]*RunTemplate[^"]*\.php"' \
| head -20 || trueRepository: VitexSoftware/multiflexi-web
Length of output: 755
🏁 Script executed:
set -u
repo='VitexSoftware/php-vitexsoftware-multiflexi-core'
sha='80eefa9362998179c5f68374ec5dc77fd605cc57'
url="https://raw.githubusercontent.com/${repo}/${sha}/src/MultiFlexi/RunTemplate.php"
echo "== ${url} =="
content="$(curl -fsSL "$url" 2>/tmp/curl-error || true)"
if [ -n "$content" ]; then
printf '%s\n' "$content" | grep -n -C 8 -E 'function[[:space:]]+cloneAs[[:space:]]*\(' || true
echo '== declarations =='
printf '%s\n' "$content" | grep -n -E 'class[[:space:]]+RunTemplate|function[[:space:]]+[A-Za-z_][A-Za-z0-9_]*[[:space:]]*\(' | head -80
else
cat /tmp/curl-error
fi
echo '== repository tree references =='
curl -fsSL "https://github.com/${repo}/tree/${sha}" 2>/tmp/tree-error \
| grep -oE 'href="[^"]*RunTemplate[^"]*"' | head -20 || cat /tmp/tree-errorRepository: VitexSoftware/multiflexi-web
Length of output: 3089
Update the locked core package before calling cloneAs().
composer.lock pins vitexsoftware/multiflexi-core to 80eefa9362998179c5f68374ec5dc77fd605cc57, which does not define RunTemplate::cloneAs(). This call fails with an undefined-method error at runtime.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/runtemplateclone.php` at line 41, Update the locked multiflexi-core
dependency to a revision that defines RunTemplate::cloneAs(), then regenerate
composer.lock and verify the updated package is installed before the
$sourceTemplate->cloneAs($cloneName) call in runtemplateclone.php.
Summary
activeverbatim from the source, so cloning an active template produced another active one that the scheduler could run before its copied config (credentials, env, cron) was reviewed.runtemplateclone.phpnow delegates toRunTemplate::cloneAs()(core), which always creates the clone withactive=false.Depends on: VitexSoftware/php-vitexsoftware-multiflexi-core#53 (adds
cloneAs()) — needs that merged/released first.Same bug fixed identically in VitexSoftware/multiflexi-web5.
Test plan
php -lon the changed fileFor SpojeNetIT.
Summary by CodeRabbit