[BUG] Double inclusion of module file
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
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;
thanks!
it's incredible, but the bug remains :( phalcon 1.2.1
Can you please compile from the ext/ directory?
cd cphalcon/ext
sudo ./install
Unable to reproduce with 412289eeb22e143d9798db39bbcc3f1880331baf
yes, sorry, from the ext/ directory all works fine
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