Skip to content

Copy page fix#432

Merged
jonasdekeukelaere merged 1 commit intomasterfrom
copy-page
Mar 5, 2026
Merged

Copy page fix#432
jonasdekeukelaere merged 1 commit intomasterfrom
copy-page

Conversation

@jonasdekeukelaere
Copy link
Member

@jonasdekeukelaere jonasdekeukelaere commented Mar 5, 2026

https://next-app.activecollab.com/108877/my-work?modal=Task-230814-4370

Summary by Sourcery

Bug Fixes:

  • Prevent default blocks from being reinitialized when adding a page via copy so the copied page content is preserved.

@sourcery-ai
Copy link

sourcery-ai bot commented Mar 5, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts page-add behavior so copied pages do not initialize default blocks, using a new template flag set when loading an original page for copying.

Sequence diagram for copy-page add flow without default blocks

sequenceDiagram
    actor Editor
    participant Browser
    participant BackendAddAction as Backend_AddAction
    participant Template as Twig_Template
    participant JS as PageAdd_JS

    Editor->>Browser: Open Add Page with copy(id)
    Browser->>BackendAddAction: GET /pages/add?copy=id
    BackendAddAction->>BackendAddAction: getOriginalPage()
    BackendAddAction->>Template: assign showCopyWarning = true
    BackendAddAction->>Template: assign isCopy = true
    BackendAddAction-->>Browser: Render Add.html.twig

    Browser->>Template: Evaluate initDefaults expression
    Template-->>Browser: var initDefaults = false

    Browser->>JS: Execute page initialization
    JS->>JS: Check initDefaults
    JS-->>JS: Skip default blocks initialization (is copy)
Loading

File-Level Changes

Change Details Files
Gate the default-blocks initialization in the Add template behind an isCopy flag so copied pages skip default block setup.
  • Replace the hardcoded JavaScript initDefaults assignment with a Twig conditional that sets it to false when rendering a copy, otherwise true
  • Ensure the conditional checks both that isCopy is defined and truthy to avoid affecting non-copy flows
src/Backend/Modules/Pages/Layout/Templates/Add.html.twig
Mark the Add template context as a copy flow when loading an original page for duplication.
  • Assign isCopy as true in the controller when an original page is successfully resolved for copying
  • Keep the existing showCopyWarning behavior while extending the template context with the new flag
src/Backend/Modules/Pages/Actions/Add.php

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Instead of checking isCopy is defined in the Twig template, consider always assigning isCopy (e.g., defaulting to false) in the controller so the template can use a simpler boolean check.
  • It may be clearer to rename initDefaults (or add a short inline comment) to explicitly indicate that it controls applying default blocks only on non-copy page loads, so future readers understand why copies skip this path.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Instead of checking `isCopy is defined` in the Twig template, consider always assigning `isCopy` (e.g., defaulting to false) in the controller so the template can use a simpler boolean check.
- It may be clearer to rename `initDefaults` (or add a short inline comment) to explicitly indicate that it controls applying default blocks only on non-copy page loads, so future readers understand why copies skip this path.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@jonasdekeukelaere jonasdekeukelaere merged commit 76ebb0c into master Mar 5, 2026
9 of 12 checks passed
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.

2 participants