Skip to content

Conversation

@d0ubIeU
Copy link
Contributor

@d0ubIeU d0ubIeU commented Jan 26, 2026

This change introduces new functionality for managing FAQs that are not assigned to a category (orphaned FAQs). Previously, the view was restricted to the currently active backend language in both the list and the editor.

The adjustments made now enable full cross-language management:

  • Comprehensive Overview: The orphaned FAQs list now displays all languages, sorted by language.
    
  • Clear Language Assignment: The overview shows the full language name (e.g., "German") instead of just the language code.
    
  • Functional Assignment: When editing an orphaned FAQ, the category list correctly filters to the language of the respective FAQ, allowing assignment to matching categories.
    

Summary by CodeRabbit

  • Bug Fixes

    • Fixed table markup in the orphaned FAQs listing.
    • Language column now shows readable/localized language names.
  • New Features

    • Orphaned FAQs list now includes entries from all languages and deduplicates by FAQ+language.
    • FAQ edit now preserves and uses the FAQ's language context and accepts form submissions for updates.

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

This change introduces new functionality for managing FAQs that are not assigned to a category (orphaned FAQs). Previously, the view was restricted to the currently active backend language in both the list and the editor.
@coderabbitai
Copy link

coderabbitai bot commented Jan 26, 2026

📝 Walkthrough

Walkthrough

Removed per-language filtering for orphaned FAQs, added per-row deduplication and ordering by language+id, integrated a Twig language-code extension and fixed the orphaned-faqs template markup, added an optional faqLanguage constructor parameter to Category, and updated the FAQ controller to pass faqLanguage and allow POST on edit.

Changes

Cohort / File(s) Summary
Template HTML & Twig usage
phpmyfaq/assets/templates/admin/content/orphaned-faqs.twig
Added missing </thead> and replaced rendering of the language cell to use the language-code Twig filter/extension (previous raw faq.language → `faq.language
Orphaned FAQ query & result shaping
phpmyfaq/src/phpMyFAQ/Administration/Faq.php
Removed the per-language WHERE clause so results span all languages; changed ORDER BY to fd.lang ASC, fd.id DESC; implemented per-row deduplication using a composite id-lang key; preserved mapping of faqId, language (code) and question.
Category language handling
phpmyfaq/src/phpMyFAQ/Category.php
Constructor signature now accepts an optional ?string $faqLanguage = null; if provided and non-empty, that language is used instead of the configuration default.
FAQ controller updates
phpmyfaq/src/phpMyFAQ/Controller/Administration/FaqController.php
Route for admin.faq.edit now allows GET and POST; extracted faqId, faqLanguage, and selectedRevisionId earlier and pass $faqLanguage into Category constructor; removed duplicate extractions.
Orphaned FAQs controller & Twig extension
phpmyfaq/src/phpMyFAQ/Controller/Administration/OrphanedFaqsController.php
Registered/added the LanguageCode Twig extension (via AttributeExtension(LanguageCodeTwigExtension::class)) into the Twig environment before rendering the orphaned-faqs view.

Sequence Diagram(s)

sequenceDiagram
  actor Admin
  participant OrphanedController as OrphanedFaqsController
  participant TwigEnv as Twig Environment
  participant FaqModel as Administration\\Faq
  participant DB as Database

  Admin->>OrphanedController: HTTP GET /admin/orphaned-faqs
  OrphanedController->>TwigEnv: addExtension(AttributeExtension(LanguageCodeTwigExtension::class)) 
  OrphanedController->>FaqModel: getOrphanedFaqs()
  FaqModel->>DB: SELECT ... (no lang WHERE) ORDER BY fd.lang ASC, fd.id DESC
  DB-->>FaqModel: rows
  FaqModel-->>OrphanedController: deduplicated FAQ list (id+lang)
  OrphanedController->>TwigEnv: render('orphaned-faqs.twig', {faqs})
  TwigEnv-->>Admin: HTML (language cell resolved via language-code extension)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibbled through queries, rows, and lines,
Unfurled the languages into friendly signs,
Closed a tag, added a filter so bright,
Passed my language gently, everything's light. ✨🫐

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main objective of the pull request: enabling cross-language management for orphaned FAQs, which is reflected across all file changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

Copy link

@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: 2

🤖 Fix all issues with AI agents
In `@phpmyfaq/src/phpMyFAQ/Administration/Faq.php`:
- Around line 243-266: When populating $data->languageName inside the loop that
processes DB rows (see the use of class_exists('\Locale') and
\Locale::getDisplayLanguage($row->lang, $currentBackendLang)), ensure you fall
back to the language code if getDisplayLanguage returns an empty string: call
\Locale::getDisplayLanguage(...) and if the result is empty or falsy, set
$data->languageName = $row->lang; otherwise use the display name; keep the
existing non-Locale branch unchanged.

In `@phpmyfaq/src/phpMyFAQ/Controller/Administration/FaqController.php`:
- Around line 249-258: The form that submits selectedRevisionId is POST but
FaqController::edit() only reads route attributes (request->attributes->get)
from a GET route, so $selectedRevisionId is never populated; fix by either
making the revision selector form use method="get" and read the value via
$request->query->get('selectedRevisionId') in edit(), or update the route that
maps to FaqController::edit to accept POST as well and read the submitted value
from $request->request->get('selectedRevisionId'); ensure the chosen approach
updates the form/method and the controller access (and tests) consistently so
$selectedRevisionId contains the submitted revision id.

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