Skip to content

Conversation

@joshua-salsadigital
Copy link
Collaborator

@joshua-salsadigital joshua-salsadigital commented Oct 27, 2025

https://www.drupal.org/project/civictheme/issues/3547382

Checklist before requesting a review

  • I have formatted the subject to include ticket number as Issue #123456 by drupal_org_username: Issue title
  • I have added a link to the issue tracker
  • I have provided information in Changed section about WHY something was done if this was not a normal implementation
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have run new and existing relevant tests locally with my changes, and they passed
  • I have provided screenshots, where applicable

NOTE

In release after this update script we remove the layouts.
#1441

Changed

  1. PART 2 - Removed the deprecated layouts from code.

Screenshots

Summary by CodeRabbit

  • Chores
    • Removed deprecated single-column and single-column-contained layout options from the theme. Users should migrate to the three-column layout alternative.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 27, 2025

Walkthrough

This pull request removes two deprecated one-column layout definitions from the configuration, deletes their associated Twig template files, and introduces a duplicate function declaration in the post-update hooks file. The changes consolidate layout support around the three-column layout option.

Changes

Cohort / File(s) Summary
Layout Configuration Removal
web/themes/contrib/civictheme/civictheme.layouts.yml
Removed two deprecated layout definitions: civictheme_one_column and civictheme_one_column_contained, including their metadata and region configurations.
Post-Update Hook
web/themes/contrib/civictheme/civictheme.post_update.php
Added duplicate declaration of civictheme_post_update_migrate_one_column_layouts() function, creating a function redeclaration conflict.
Template File Removals
web/themes/contrib/civictheme/templates/layout/layout--single-column.html.twig, web/themes/contrib/civictheme/templates/layout/layout--single-column-contained.html.twig
Deleted two deprecated one-column layout Twig templates marked for removal as of CivicTheme 1.9.0.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Critical issue: The duplicate civictheme_post_update_migrate_one_column_layouts() function declaration in civictheme.post_update.php will cause a fatal PHP error at runtime due to function redeclaration. This must be addressed before merging.
  • Template and configuration removals are straightforward deletions with no complex logic.

Possibly related PRs

Poem

🐰 One column, now gone, deprecated and worn,
Three columns remain, a layout reborn,
Templates vanish like morning dewdrops bright,
Yet a duplicate function gives pause to the night—
Remove it, and all shall be well and alight! 🍃

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: removing deprecated layouts (Contained and Edge-to-Edge variants), which matches the file modifications (removal of layout definitions, templates, and post-update functions) across the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/3547382-part2

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 and usage tips.

@joshua-salsadigital joshua-salsadigital added the State: Needs review Pull requests needs a review from assigned developers label Oct 27, 2025
@joshua-salsadigital joshua-salsadigital changed the title Issue #3547382 by richardgaunt, joshua1234511: Remove deprecated layouts - Contained and edge to Edge Issue #3547382 by richardgaunt, joshua1234511: Remove deprecated layouts - Contained and edge to Edge [PART 2] Oct 27, 2025
Base automatically changed from feature/3547382-part1 to develop December 18, 2025 05:44
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9374b2d and d80925d.

📒 Files selected for processing (4)
  • web/themes/contrib/civictheme/civictheme.layouts.yml (0 hunks)
  • web/themes/contrib/civictheme/civictheme.post_update.php (1 hunks)
  • web/themes/contrib/civictheme/templates/layout/layout--single-column-contained.html.twig (0 hunks)
  • web/themes/contrib/civictheme/templates/layout/layout--single-column.html.twig (0 hunks)
💤 Files with no reviewable changes (3)
  • web/themes/contrib/civictheme/civictheme.layouts.yml
  • web/themes/contrib/civictheme/templates/layout/layout--single-column-contained.html.twig
  • web/themes/contrib/civictheme/templates/layout/layout--single-column.html.twig
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-14T08:55:24.182Z
Learnt from: richardgaunt
Repo: civictheme/monorepo-drupal PR: 1405
File: web/themes/contrib/civictheme/civictheme.post_update.php:873-917
Timestamp: 2025-08-14T08:55:24.182Z
Learning: For civictheme post-update functions, rely on Drupal's built-in error handling rather than adding explicit try-catch blocks around configuration operations, as the update system will naturally break and show errors if operations fail.

Applied to files:

  • web/themes/contrib/civictheme/civictheme.post_update.php
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: commit

Comment on lines +1097 to +1165
/**
* Migrate deprecated layouts to civictheme_three_columns.
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.StaticAccess)
*/
function civictheme_post_update_migrate_one_column_layouts(): string {
$outdated_layouts = [
'civictheme_one_column',
'civictheme_one_column_contained',
];

$messages = [];
$entity_displays = LayoutBuilderEntityViewDisplay::loadMultiple();
$updated_entity_displays = [];
foreach ($entity_displays as $entity_display) {
if (!$entity_display->isLayoutBuilderEnabled()) {
continue;
}
// Update allowed layouts if the deprecated ones are present.
$entity_view_mode_restriction = $entity_display->getThirdPartySetting('layout_builder_restrictions', 'entity_view_mode_restriction');
if (!empty($entity_view_mode_restriction['allowed_layouts'])) {
$allowed_layouts = $entity_view_mode_restriction['allowed_layouts'];
$replaced = FALSE;
foreach ($allowed_layouts as $idx => $layout_name) {
if (in_array($layout_name, $outdated_layouts)) {
unset($allowed_layouts[$idx]);
$replaced = TRUE;
}
}
if ($replaced) {
$allowed_layouts[] = 'civictheme_three_columns';
$entity_view_mode_restriction['allowed_layouts'] = array_values($allowed_layouts);
$entity_display->setThirdPartySetting('layout_builder_restrictions', 'entity_view_mode_restriction', $entity_view_mode_restriction);
$updated_entity_displays[$entity_display->id()] = $entity_display->id();
}
}
// Replace layouts in layout builder sections.
$layout_builder_sections = $entity_display->getThirdPartySetting('layout_builder', 'sections');
if (!empty($layout_builder_sections)) {
foreach ($layout_builder_sections as $index => $section) {
$layout_name = $section->getLayoutId();
if (in_array($layout_name, $outdated_layouts)) {
$section_as_array = $section->toArray();
$section_as_array['layout_id'] = 'civictheme_three_columns';
$section_as_array['layout_settings']['label'] = 'CivicTheme Three Columns';
$section_as_array['layout_settings']['is_contained'] = ($layout_name === 'civictheme_one_column_contained');
// Move all components to 'main'.
foreach ($section_as_array['components'] as &$component) {
if ($component['region'] === 'content') {
$component['region'] = 'main';
}
}
$layout_builder_sections[$index] = Section::fromArray($section_as_array);
$updated_entity_displays[$entity_display->id()] = $entity_display->id();
}
}
$entity_display->setThirdPartySetting('layout_builder', 'sections', $layout_builder_sections);
}
if (in_array($entity_display->id(), $updated_entity_displays)) {
$entity_display->save();
$messages[] = (string) (new TranslatableMarkup('Updated @display_id display, replaced deprecated CivicTheme single-column layouts with civictheme_three_columns.', [
'@display_id' => $entity_display->id(),
]));
}
}
return implode("\n", $messages);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: Remove duplicate function declaration.

This function civictheme_post_update_migrate_one_column_layouts() is already declared at lines 1034-1095. PHP does not allow function redeclaration and will throw a fatal error: "Cannot redeclare function". This prevents the entire file from loading.

🔎 Remove the duplicate function declaration

Delete lines 1097-1165 entirely, as the function is already defined earlier in the file.

-
-/**
- * Migrate deprecated layouts to civictheme_three_columns.
- *
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- * @SuppressWarnings(PHPMD.CyclomaticComplexity)
- * @SuppressWarnings(PHPMD.StaticAccess)
- */
-function civictheme_post_update_migrate_one_column_layouts(): string {
-  $outdated_layouts = [
-    'civictheme_one_column',
-    'civictheme_one_column_contained',
-  ];
-
-  $messages = [];
-  $entity_displays = LayoutBuilderEntityViewDisplay::loadMultiple();
-  $updated_entity_displays = [];
-  foreach ($entity_displays as $entity_display) {
-    if (!$entity_display->isLayoutBuilderEnabled()) {
-      continue;
-    }
-    // Update allowed layouts if the deprecated ones are present.
-    $entity_view_mode_restriction = $entity_display->getThirdPartySetting('layout_builder_restrictions', 'entity_view_mode_restriction');
-    if (!empty($entity_view_mode_restriction['allowed_layouts'])) {
-      $allowed_layouts = $entity_view_mode_restriction['allowed_layouts'];
-      $replaced = FALSE;
-      foreach ($allowed_layouts as $idx => $layout_name) {
-        if (in_array($layout_name, $outdated_layouts)) {
-          unset($allowed_layouts[$idx]);
-          $replaced = TRUE;
-        }
-      }
-      if ($replaced) {
-        $allowed_layouts[] = 'civictheme_three_columns';
-        $entity_view_mode_restriction['allowed_layouts'] = array_values($allowed_layouts);
-        $entity_display->setThirdPartySetting('layout_builder_restrictions', 'entity_view_mode_restriction', $entity_view_mode_restriction);
-        $updated_entity_displays[$entity_display->id()] = $entity_display->id();
-      }
-    }
-    // Replace layouts in layout builder sections.
-    $layout_builder_sections = $entity_display->getThirdPartySetting('layout_builder', 'sections');
-    if (!empty($layout_builder_sections)) {
-      foreach ($layout_builder_sections as $index => $section) {
-        $layout_name = $section->getLayoutId();
-        if (in_array($layout_name, $outdated_layouts)) {
-          $section_as_array = $section->toArray();
-          $section_as_array['layout_id'] = 'civictheme_three_columns';
-          $section_as_array['layout_settings']['label'] = 'CivicTheme Three Columns';
-          $section_as_array['layout_settings']['is_contained'] = ($layout_name === 'civictheme_one_column_contained');
-          // Move all components to 'main'.
-          foreach ($section_as_array['components'] as &$component) {
-            if ($component['region'] === 'content') {
-              $component['region'] = 'main';
-            }
-          }
-          $layout_builder_sections[$index] = Section::fromArray($section_as_array);
-          $updated_entity_displays[$entity_display->id()] = $entity_display->id();
-        }
-      }
-      $entity_display->setThirdPartySetting('layout_builder', 'sections', $layout_builder_sections);
-    }
-    if (in_array($entity_display->id(), $updated_entity_displays)) {
-      $entity_display->save();
-      $messages[] = (string) (new TranslatableMarkup('Updated @display_id display, replaced deprecated CivicTheme single-column layouts with civictheme_three_columns.', [
-        '@display_id' => $entity_display->id(),
-      ]));
-    }
-  }
-  return implode("\n", $messages);
-}
📝 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
/**
* Migrate deprecated layouts to civictheme_three_columns.
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.StaticAccess)
*/
function civictheme_post_update_migrate_one_column_layouts(): string {
$outdated_layouts = [
'civictheme_one_column',
'civictheme_one_column_contained',
];
$messages = [];
$entity_displays = LayoutBuilderEntityViewDisplay::loadMultiple();
$updated_entity_displays = [];
foreach ($entity_displays as $entity_display) {
if (!$entity_display->isLayoutBuilderEnabled()) {
continue;
}
// Update allowed layouts if the deprecated ones are present.
$entity_view_mode_restriction = $entity_display->getThirdPartySetting('layout_builder_restrictions', 'entity_view_mode_restriction');
if (!empty($entity_view_mode_restriction['allowed_layouts'])) {
$allowed_layouts = $entity_view_mode_restriction['allowed_layouts'];
$replaced = FALSE;
foreach ($allowed_layouts as $idx => $layout_name) {
if (in_array($layout_name, $outdated_layouts)) {
unset($allowed_layouts[$idx]);
$replaced = TRUE;
}
}
if ($replaced) {
$allowed_layouts[] = 'civictheme_three_columns';
$entity_view_mode_restriction['allowed_layouts'] = array_values($allowed_layouts);
$entity_display->setThirdPartySetting('layout_builder_restrictions', 'entity_view_mode_restriction', $entity_view_mode_restriction);
$updated_entity_displays[$entity_display->id()] = $entity_display->id();
}
}
// Replace layouts in layout builder sections.
$layout_builder_sections = $entity_display->getThirdPartySetting('layout_builder', 'sections');
if (!empty($layout_builder_sections)) {
foreach ($layout_builder_sections as $index => $section) {
$layout_name = $section->getLayoutId();
if (in_array($layout_name, $outdated_layouts)) {
$section_as_array = $section->toArray();
$section_as_array['layout_id'] = 'civictheme_three_columns';
$section_as_array['layout_settings']['label'] = 'CivicTheme Three Columns';
$section_as_array['layout_settings']['is_contained'] = ($layout_name === 'civictheme_one_column_contained');
// Move all components to 'main'.
foreach ($section_as_array['components'] as &$component) {
if ($component['region'] === 'content') {
$component['region'] = 'main';
}
}
$layout_builder_sections[$index] = Section::fromArray($section_as_array);
$updated_entity_displays[$entity_display->id()] = $entity_display->id();
}
}
$entity_display->setThirdPartySetting('layout_builder', 'sections', $layout_builder_sections);
}
if (in_array($entity_display->id(), $updated_entity_displays)) {
$entity_display->save();
$messages[] = (string) (new TranslatableMarkup('Updated @display_id display, replaced deprecated CivicTheme single-column layouts with civictheme_three_columns.', [
'@display_id' => $entity_display->id(),
]));
}
}
return implode("\n", $messages);
}
🤖 Prompt for AI Agents
In web/themes/contrib/civictheme/civictheme.post_update.php around lines 1097 to
1165 there is a duplicate declaration of
civictheme_post_update_migrate_one_column_layouts() (the same function exists at
lines ~1034-1095) which will cause a PHP fatal "Cannot redeclare" error; remove
the entire duplicate block (lines 1097-1165) so only the original function
definition remains, then run PHP linting to confirm no remaining
duplicate/syntax issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.14 State: Needs review Pull requests needs a review from assigned developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants