Refactor wizard helpers by NB-Core · Pull Request #14 · NB-Core/modules · GitHub
Skip to content

Refactor wizard helpers#14

Merged
NB-Core merged 3 commits into
tlwizardfrom
codex/refactor-to-use-wizardservice-methods
Jul 13, 2025
Merged

Refactor wizard helpers#14
NB-Core merged 3 commits into
tlwizardfrom
codex/refactor-to-use-wizardservice-methods

Conversation

@NB-Core

@NB-Core NB-Core commented Jul 13, 2025

Copy link
Copy Markdown
Owner

Summary

  • move batch and copy helpers into WizardService
  • use the new helpers from list.php
  • inline randomsave handling
  • drop now unused scripts

Testing

  • php -l systems/translationwizard/translationwizard/WizardService.php
  • php -l systems/translationwizard/translationwizard/list.php
  • php -l systems/translationwizard/translationwizard.php

https://chatgpt.com/codex/tasks/task_e_6873d43ae3f88329bb8484779922221f

@NB-Core NB-Core requested a review from Copilot July 13, 2025 16:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

Refactors translation wizard helpers by centralizing save and copy operations in WizardService, updating entry points to use these helpers, and removing now-obsolete standalone scripts.

  • Removes individual scripts (save_single.php, randomsave.php, multichecked.php, copychecked.php) in favor of service methods.
  • Adds copyCheckedTranslations and saveBatchTranslations to WizardService.
  • Updates list.php and translationwizard.php to call new service methods and inline the random-save flow.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
systems/translationwizard/translationwizard/save_single.php Deleted obsolete single-save script (logic moved into WizardService).
systems/translationwizard/translationwizard/randomsave.php Deleted and inlined its logic into translationwizard.php.
systems/translationwizard/translationwizard/multichecked.php Deleted batch-checked script (replaced by WizardService::saveBatchTranslations).
systems/translationwizard/translationwizard/copychecked.php Deleted copy-checked script (replaced by WizardService::copyCheckedTranslations).
systems/translationwizard/translationwizard/list.php Replaced script includes with service calls for batch and copy operations.
systems/translationwizard/translationwizard/WizardService.php Added copyCheckedTranslations and saveBatchTranslations methods.
systems/translationwizard/translationwizard.php Inlined random-save handling into the main controller.
Comments suppressed due to low confidence (1)

systems/translationwizard/translationwizard/list.php:33

  • The call to WizardService::ensureArray will fail if ensureArray is not defined in WizardService. Please implement ensureArray or replace it with a function that safely handles scalar vs. array inputs.
                WizardService::ensureArray($transintext),

Comment on lines +167 to +168
} else {
require("./modules/translationwizard/$op.php");

Copilot AI Jul 13, 2025

Copy link

Choose a reason for hiding this comment

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

Legacy operations like save_single, multichecked, and copychecked have been removed but will still be required here when $op matches those names. Add explicit handling or routing for those operations to avoid runtime include errors.

Suggested change
} else {
require("./modules/translationwizard/$op.php");
} elseif (in_array($op, ['save_single', 'multichecked', 'copychecked'])) {
// Explicit handling for legacy operations
require("./modules/translationwizard/legacy/$op.php");
} elseif (in_array($op, ['default', 'scanmodules', 'other_valid_op'])) {
// Validate $op against a whitelist of allowed operations
require("./modules/translationwizard/$op.php");
} else {
// Fallback for unknown operations
output("Invalid operation specified.");

Copilot uses AI. Check for mistakes.

Copilot AI Jul 13, 2025

Copy link

Choose a reason for hiding this comment

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

This SQL update uses unescaped user input ($out), which can lead to SQL injection. Consider using parameterized queries or a proper escaping function instead of directly interpolating variables.

Copilot uses AI. Check for mistakes.
Comment thread systems/translationwizard/translationwizard/WizardService.php
Comment thread systems/translationwizard/translationwizard/WizardService.php
Comment thread systems/translationwizard/translationwizard/WizardService.php Outdated
Comment thread systems/translationwizard/translationwizard/list.php Outdated
NB-Core and others added 2 commits July 13, 2025 18:09
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@NB-Core NB-Core merged commit 5c598e4 into tlwizard Jul 13, 2025
@NB-Core NB-Core deleted the codex/refactor-to-use-wizardservice-methods branch July 13, 2025 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants