Skip to content

Update UpdatefromcliCommand.php#35

Merged
alikon merged 2 commits intomainfrom
alikon-patch-1
Mar 11, 2026
Merged

Update UpdatefromcliCommand.php#35
alikon merged 2 commits intomainfrom
alikon-patch-1

Conversation

@alikon
Copy link
Copy Markdown
Owner

@alikon alikon commented Mar 11, 2026

see discussion here joomla/joomla-cms#47203 (comment)

Summary by Sourcery

Enhancements:

  • Move and extend language loading in the update-from-CLI console command so language keys are available earlier in the execution flow.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Mar 11, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Moves and expands language loading so update-related language keys (including lib_joomla) are initialized before extension updates are fetched and displayed in the CLI command, instead of only loading com_installer after rendering the table.

Sequence diagram for updated language loading in UpdatefromcliCommand execution

sequenceDiagram
    actor CliUser
    participant SymfonyConsole as SymfonyConsole_Application
    participant UpdatefromcliCommand as UpdatefromcliCommand
    participant JoomlaApp as Joomla_Application
    participant Language as Language
    participant InstallerComponent as Com_installer_Component
    participant UpdateModel as UpdateModel

    CliUser->>SymfonyConsole: run updatefromcli command
    SymfonyConsole->>UpdatefromcliCommand: doExecute(input, output)

    UpdatefromcliCommand->>JoomlaApp: getLanguage()
    JoomlaApp-->>UpdatefromcliCommand: Language

    UpdatefromcliCommand->>Language: load(lib_joomla, JPATH_ADMINISTRATOR)
    UpdatefromcliCommand->>Language: load(com_installer, JPATH_ADMINISTRATOR, en-GB, false, true)
    UpdatefromcliCommand->>Language: load(com_installer, JPATH_ADMINISTRATOR, null, true)

    UpdatefromcliCommand->>JoomlaApp: bootComponent(com_installer)
    JoomlaApp-->>UpdatefromcliCommand: InstallerComponent
    UpdatefromcliCommand->>InstallerComponent: getMVCFactory()
    InstallerComponent-->>UpdatefromcliCommand: MVCFactory
    UpdatefromcliCommand->>InstallerComponent: createModel(Update)
    InstallerComponent-->>UpdatefromcliCommand: UpdateModel

    UpdatefromcliCommand->>UpdateModel: findUpdates()
    UpdateModel-->>UpdatefromcliCommand: updates

    UpdatefromcliCommand->>UpdatefromcliCommand: getExtensionInfo(updates)
    UpdatefromcliCommand->>SymfonyConsole: render table with extensions

    UpdatefromcliCommand-->>SymfonyConsole: return status code
    SymfonyConsole-->>CliUser: output result
Loading

Updated class diagram for UpdatefromcliCommand language handling

classDiagram
    class UpdatefromcliCommand {
        - application : Joomla_Application
        + doExecute(input : InputInterface, output : OutputInterface) int
        - getExtensionInfo(update : mixed) array
    }

    class Joomla_Application {
        + getLanguage() Language
        + bootComponent(option : string) Component
    }

    class Language {
        + load(extension : string, basePath : string)
        + load(extension : string, basePath : string, language : string, reload : bool, default : bool)
    }

    class Component {
        + getMVCFactory() MVCFactory
        + createModel(name : string) Model
    }

    class MVCFactory {
        + createModel(name : string) Model
    }

    class UpdateModel {
        + findUpdates() array
    }

    class InputInterface
    class OutputInterface

    UpdatefromcliCommand --> Joomla_Application : uses
    UpdatefromcliCommand --> Language : loads_strings_via
    UpdatefromcliCommand --> UpdateModel : uses
    Joomla_Application --> Language : provides
    Joomla_Application --> Component : boots
    Component --> MVCFactory : provides
    MVCFactory --> UpdateModel : creates
Loading

File-Level Changes

Change Details Files
Load Joomla core and installer language files earlier in the CLI update command execution.
  • Add loading of the global Joomla library language file before running the update lookup.
  • Move com_installer language loading from after the extensions table output to before the update model is bootstrapped and invoked.
  • Ensure both the en-GB base and current-language com_installer language files are loaded with the appropriate administrator path and fallback behavior.
src/plugins/console/updatefromcli/src/CliCommand/UpdatefromcliCommand.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
Copy Markdown

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

  • The new language-loading block mixes tabs and spaces for indentation; align it with the existing coding style in this file for consistency.
  • The comment // Load languages key is a bit unclear—consider rephrasing it to something more descriptive like // Load core and installer language files so future readers immediately understand the purpose.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new language-loading block mixes tabs and spaces for indentation; align it with the existing coding style in this file for consistency.
- The comment `// Load languages key` is a bit unclear—consider rephrasing it to something more descriptive like `// Load core and installer language files` so future readers immediately understand the purpose.

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.

@alikon alikon merged commit 8d823c7 into main Mar 11, 2026
26 checks passed
@alikon alikon deleted the alikon-patch-1 branch March 11, 2026 09:44
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