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

Already on GitHub? Sign in to your account

1.1.13 bug in setComponents #1906

Closed
adminnu opened this Issue Dec 31, 2012 · 15 comments

Comments

4 participants
Contributor

adminnu commented Dec 31, 2012

Hello!

We have a component, named 'user', after
3e3deac , it could not be loaded anymore.

When module is specified as 'users', all works fine.

We spent some time in bug-tracing and found, that 'user' can be finded here 3e3deac#L0R495 and ignored then.

pull #1491

Contributor

adminnu commented Dec 31, 2012

coreMessages
db
messages
errorHandler
securityManager
statePersister
urlManager
request
format


session
assetManager
user
themeManager
authManager
clientScript
widgetFactory


migrator
image
urlManager
urlManager-
request
request-
ajax
cache
log
curl
mail
mailMessage
queue
loid
eauth
user
user-
db

setComponents all-time place 3 times, separated by ---, where the name of the module, - is when the unit enters the block with continue.

Contributor

adminnu commented Dec 31, 2012

Now it turns out that the error here 3e3deac#L0R468 If you remove this block.
Since this block is called the fourth iteration.

Contributor

adminnu commented Dec 31, 2012

Dug further if launcher gii Yii :: app () -> getModule ('gii');
When gii is setComponents in which we find ourselves on the line 3e3deac#L0R468 and here 3e3deac#L0R475

we

$id - user,
$config - array(3) { ["class"]=> string(8) "CWebUser" ["stateKeyPrefix"]=> string(3) "gii" ["loginUrl"]=> string(21) "/en/gii/default/login" }  

config ling gii:

'gii'   => array(
        'class'          => 'system.gii.GiiModule',
        'password'       => 'giiYupe',
        'generatorPaths' => array(
            'application.modules.yupe.extensions.yupe.gii',
        ),
        'ipFilters'=>array(),
    ),
Contributor

adminnu commented Dec 31, 2012

In gii module, init has such lines: https://github.com/yiisoft/yii/blob/1.1.13/framework/gii/GiiModule.php#L122
In the which is redefining user, which also applies to all other modules.

Contributor

adminnu commented Jan 9, 2013

I would like to consider the matter, as it is critical for some modules.

@cebe cebe was assigned Jan 9, 2013

Owner

cebe commented Jan 9, 2013

Thanks for reporting, will check it today.

Owner

cebe commented Jan 11, 2013

Tried to reproduce this but I was not able to find the problem.
I also have a custom user component but when I use gii in my app it replaces the user component without any problem.

Can you provide steps how to reproduce this problem?

Contributor

adminnu commented Jan 11, 2013

Look.

  1. Turn on your component and the component user gii.
  2. On the run the two methods: Yii::app()->getModule('gii'); and followed the method of the component user, which is not present in the standard class, to see that when you run the method of user request is the component user connected to gii.
Contributor

magefad commented Jan 11, 2013

In short, Yii::app()->getModule('gii') overrides the user component (example specified in config/main.php).
faced a similar problem

Contributor

adminnu commented Jan 11, 2013

Yes, setComponets overrides components and it is available globally.

@cebe cebe added a commit to cebe/yupe that referenced this issue Jan 11, 2013

@cebe cebe Fix Problem with user component loading GiiModule
For a simple check if gii is installed it does not have to be instanciated. So gii will not overwrite existing application components. 

Related issues:
yiisoft/yii#1906
yupe/yupe#381
1dab56a
Owner

cebe commented Jan 11, 2013

Okay I got it. So gii is reconfiguring user component for its own login page. And you are loading gii module inside another module which then kills your user component.

For current issue in yupe you can simply check for gii existence by calling hasModule() instead of getModule(). See my pull request: yupe/yupe#478

I don't see a reasong to change something right now. Is there any problem with other modules except from gii @magefad ?

Contributor

magefad commented Jan 11, 2013

Just had to continue; if the module == gii
in this code

        foreach (Yii::app()->getModules() as $module => $config)
        {
            Yii::app()->getModule($module);
        }
        Yii::app()->urlManager->collectRules();
Contributor

adminnu commented Jan 11, 2013

@cebe
Thanks for the commit. Yes, there really needed hasModule.
But we have 2-3 places where there is a search for all the modules to produce and parameters.
https://github.com/cebe/yupe/blob/1dab56a1c36b1d21be980eee2d370951aa44f132/protected/modules/menu/models/MenuItem.php#L243
https://github.com/cebe/yupe/blob/1dab56a1c36b1d21be980eee2d370951aa44f132/protected/modules/yupe/YupeModule.php#L264

Really can be excluded, gii, but it may be the second such unit, and it will be difficult to track, and is it normal that the components used in the module affect all the others. I think everyone should affect only the components attached to main.php
I think the components are loaded in the module should be limited to the module.

Simply whether the behavior was normal. To this problem affects
https://github.com/yiisoft/yii/blob/master/framework/base/CModule.php#L427


@magefad
There are times when you need to take all of the modules and get them parammetry, including modules yii.
The same situation may arise when the module need to override the component and then it may be the problem.

@cebe cebe added a commit to cebe/yii that referenced this issue Jan 11, 2013

@cebe cebe Move gii application components to beforeAction
GiiModule should only adjust environment when it actually runs a
controller action. It should not affect app in other cases.

see issue #1906 for details
4ab3221
Owner

cebe commented Jan 11, 2013

@adminnu moved the applicaion component code in GiiModule to beforeControllerAction() so it now only affects application if it runs a controller action itself. #1958

Contributor

adminnu commented Jan 11, 2013

@cebe Super. Thank you. I need to remember how to connect the components in the module. The method tested, everything works well. I hope you will apply it or any other solution.

@samdark samdark closed this Nov 17, 2015

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