refactor code to remove Drush command calling another command

Created on 8 January 2024, 6 months ago
Updated 15 January 2024, 5 months ago

Problem/Motivation

The tome:static command's command class, StaticCommand, calls a helper method, exportPaths().

The exportPaths method then builds up an array of commands to ANOTHER Drush command:

      $command = [$this->executable, 'tome:static-export-path', implode(',', $chunk), '--return-json', '--process-count=' . $process_count, '--uri=' . $uri];
      $commands[] = $command;
SNIP
    $collected_errors = $this->runCommands($commands, $process_count, $retry_count, function (Process $process) use ($show_progress, &$invoke_paths, $path_count) {

Just to complicate things further, the command it's calling, 'tome:static-export-path' is defined in the class StaticExportPathCommand, which inherits from StaticCommand, and the command callback calls exportPaths()!!!!

This is really confusing, and the code is not commented to explain the reason for this.

I'd be inclined to move the common code to a service -- or is there a reason for all this complicated stuff? What is it?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Active

Version

1.0

Component

Tome Static

Created by

πŸ‡¬πŸ‡§United Kingdom joachim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @joachim
  • πŸ‡¬πŸ‡§United Kingdom joachim

    It's also really confusing that exportPaths() doesn't export paths -- or at least not all of them! --

        $paths = $this->static->exportPaths($paths);
    

    and:

      _tome_static_cron_queue_paths($static->exportPaths($static->getPaths()), $base_url);
    
Production build 0.69.0 2024