Skip to content

Force clone RunTemplates to be created disabled - #7

Merged
Vitexus merged 1 commit into
mainfrom
fix/runtemplate-clone-disabled
Aug 12, 2026
Merged

Force clone RunTemplates to be created disabled#7
Vitexus merged 1 commit into
mainfrom
fix/runtemplate-clone-disabled

Conversation

@Vitexus

@Vitexus Vitexus commented Aug 12, 2026

Copy link
Copy Markdown
Member

Summary

  • Cloning a RunTemplate (the "💕 Clone" button) copied active verbatim 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.php now delegates to RunTemplate::cloneAs() (core), which always creates the clone with active=false.
  • Success message now tells the user the clone is disabled and needs review.

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 -l on the changed file
  • Manual: clone an active RunTemplate in the UI, confirm it lists as Disabled and the scheduler skips it

For SpojeNetIT.

Summary by CodeRabbit

  • Bug Fixes
    • Improved runtemplate cloning reliability by using the standard cloning process.
    • Newly cloned runtemplates are disabled until they can be reviewed.

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>
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The runtemplate clone script now delegates cloning to RunTemplate::cloneAs(). It removes unused imports and reports that the cloned runtemplate is disabled pending review.

Changes

Runtemplate cloning

Layer / File(s) Summary
Delegate cloning and report review state
src/runtemplateclone.php
The script removes unused imports, uses cloneAs($cloneName), and updates the success message to describe the disabled clone state.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: cloned RunTemplates are created disabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/runtemplate-clone-disabled

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 paths: directive.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 38a3710 and 93bfed0.

📒 Files selected for processing (1)
  • src/runtemplateclone.php

Comment thread 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 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'
fi

Repository: 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",""))'
fi

Repository: 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 || true

Repository: 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-error

Repository: 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.

@Vitexus
Vitexus merged commit 5807602 into main Aug 12, 2026
1 of 2 checks passed
@Vitexus
Vitexus deleted the fix/runtemplate-clone-disabled branch August 12, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant