Skip to content
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

[BUG] Double inclusion of module file #812

Closed
beermeat opened this issue Jul 9, 2013 · 7 comments
Closed

[BUG] Double inclusion of module file #812

beermeat opened this issue Jul 9, 2013 · 7 comments

Comments

@beermeat
Copy link

beermeat commented Jul 9, 2013

simple multimodule app:

$application = new Application($di);

// Register the installed modules
$application->registerModules(array(
    'default' => array(
        'className' => 'Multiple\Frontend\Module',
        'path'      => '../apps/frontend/Module.php',
    )
));

call handle:

echo $application->handle('/foo/bar/')->getContent();

its ok.

then make a second call:

echo $application->handle('/bla/bla/')->getContent();

oops, an error:

Fatal error: Cannot redeclare class Module in apps/frontend/Module.php on line 6

phalcon 1.2

@ghost
Copy link

ghost commented Jul 9, 2013

Confirmed, the bug is caused by phalcon_require:

            if (phalcon_array_isset_string(module, SS("path"))) {

                PHALCON_OBS_VAR(path);
                phalcon_array_fetch_string(&path, module, SL("path"), PH_NOISY_CC);
                if (phalcon_file_exists(path TSRMLS_CC) == SUCCESS) {
                    if (phalcon_require(path TSRMLS_CC) == FAILURE) {
                        return;
                    }
                } else {
                    PHALCON_INIT_NVAR(exception_msg);
                    PHALCON_CONCAT_SVS(exception_msg, "Module definition path '", path, "' doesn't exist");
                    PHALCON_THROW_EXCEPTION_ZVAL(phalcon_mvc_application_exception_ce, exception_msg);
                    return;
                }
            }

A quick workaround:

if (!class_exists('Module')) :

class Module { /* your code here */ }

endif;

@beermeat
Copy link
Author

thanks!

@beermeat
Copy link
Author

it's incredible, but the bug remains :(
phalcon 1.2.1

@beermeat beermeat reopened this Jul 11, 2013
@phalcon
Copy link
Collaborator

phalcon commented Jul 11, 2013

Can you please compile from the ext/ directory?

cd cphalcon/ext
sudo ./install

@ghost
Copy link

ghost commented Jul 11, 2013

Unable to reproduce with 412289e

@beermeat
Copy link
Author

yes, sorry, from the ext/ directory all works fine

@fabfuel
Copy link

fabfuel commented Jan 26, 2014

This bug is still present in 1.2.5

When forwarding a CLI call and defining the (same) module:

$this->application->handle(array(
    'module' => 'api',
    'task' => 'main',
    'action' => 'foobar'
));

The module bootstrap is included a second time:

Fatal error: Cannot redeclare class MyApp\Api\Module in /www/myapp/application/modules/api/Module.php on line 10

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

No branches or pull requests

2 participants