New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling a module twice causes class already exists error #13724

Closed
npfedwards opened this Issue Dec 31, 2018 · 0 comments

Comments

Projects
2 participants
@npfedwards
Copy link
Contributor

npfedwards commented Dec 31, 2018

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

@niden niden added this to To do in 4.0 Release via automation Jan 4, 2019

@niden niden added the Bug - Medium label Jan 4, 2019

npfedwards added a commit to npfedwards/cphalcon that referenced this issue Jan 6, 2019

@npfedwards npfedwards referenced this issue Jan 6, 2019

Merged

Tests for Cli/Console #13719

3 of 3 tasks complete

niden added a commit that referenced this issue Jan 10, 2019

Merge branch 'phalcon-4.0.x' of https://github.com/npfedwards/cphalcon
…into npfedwards-phalcon-4.0.x

* 'phalcon-4.0.x' of https://github.com/npfedwards/cphalcon:
  Add to changelog and split out tests
  Fix for #13724
  Update docblocks
  Fix most of the issues
  PHPCS fixes
  Final Cli Console tests
  __get() test and Set Argument test working. Still to do HandleCest
  Getting there on Cli\Console tests.

niden added a commit that referenced this issue Jan 10, 2019

Merge branch 'npfedwards-phalcon-4.0.x' into 4.0.x
* npfedwards-phalcon-4.0.x:
  Add to changelog and split out tests
  Fix for #13724
  Update docblocks
  Fix most of the issues
  PHPCS fixes
  Final Cli Console tests
  __get() test and Set Argument test working. Still to do HandleCest
  Getting there on Cli\Console tests.

niden added a commit to niden/cphalcon that referenced this issue Jan 10, 2019

[4.0.x] - Merge remote-tracking branch 'upstream/4.0.x' into 4.0.x
* upstream/4.0.x:
  Add to changelog and split out tests
  Fix for phalcon#13724
  Update docblocks
  Fix most of the issues
  PHPCS fixes
  Final Cli Console tests
  __get() test and Set Argument test working. Still to do HandleCest
  Getting there on Cli\Console tests.

niden added a commit to niden/cphalcon that referenced this issue Jan 10, 2019

[phalcon#13758] - Merge branch '4.0.x' into T13758-acl-default-access…
…-level

* 4.0.x:
  Add to changelog and split out tests
  Fix for phalcon#13724
  Update docblocks
  Fix most of the issues
  PHPCS fixes
  Final Cli Console tests
  __get() test and Set Argument test working. Still to do HandleCest
  Getting there on Cli\Console tests.

@npfedwards npfedwards closed this Jan 13, 2019

4.0 Release automation moved this from To do to Done Jan 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment