Skip to content

Handling a module twice causes class already exists error #13724

Closed
@npfedwards

Description

Expected and Actual Behavior

This is very much an edge case and may only ever show up in testing, however, it does appear to be a bug.

Consider the following code (assuming we have the appropriate Main tasks set up)

$console = new Cli\Console($di);
$console->registerModules(
            [
                "frontend" => [
                    "className" => "Phalcon\\Test\\Modules\\Frontend\\Module",
                    "path" => __DIR__ . "/../../../_data/modules/frontend/Module.php",
                ]
            ]
        );
$console->handle(["module"=>"frontend"]);
$console = new Cli\Console($di);
$console->registerModules(
            [
                "frontend" => [
                    "className" => "Phalcon\\Test\\Modules\\Frontend\\Module",
                    "path" => __DIR__ . "/../../../_data/modules/frontend/Module.php",
                ]
            ]
        );
$console->handle(["module"=>"frontend"]);

One would expect this to run the main task twice, but on the second handle() we get a class already exists error. Removing the "path" argument fixes this, but we should be using a require_once (or Zephir equivalent).

Details

  • Phalcon version: 4.0.x
  • PHP Version: 7.2.13
  • Operating System: nanobox

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions