zikula / core

Zikula Core Framework
GNU Lesser General Public License v3.0
237 stars 66 forks source link

Undefined index: __request #1677

Closed shefik closed 10 years ago

shefik commented 10 years ago

I keep getting this error on a clean install of Zikula

ContextErrorException: Notice: Undefined index: __request in /src/lib/legacy/Zikula/ServiceManager.php line 114

cmfcmf commented 10 years ago

I've also seen this error. However I'm not entirely sure the way you fix it in your PR is the intended way. I also don't know why the request is handled in such a way, maybe @drak knows more about it?

cmfcmf commented 10 years ago

That's how my workaround looked like (however I'm not sure what exactly is going on there)

 if ($id === 'request' && isset($GLOBALS['__request'])) {
      return $GLOBALS['__request'];
 }
ghost commented 10 years ago

I think the PR is wrong. We're trying to wire in Symfony's way of doing things. That means we inject the request from the front controller only so using Request::create arbitrarily in the code is not ok really. (because of subrequests).

shefik commented 10 years ago

@drak So, are you saying the correct code should be what @cmfcmf posted above? If so, then why isn't $GLOBALS['request'] already available, if it's being set in the init function? It looks like somewhere, code is calling to retrieve $GLOBALS['request'] prior to init, so it's apparently needed.

craigh commented 10 years ago

I am also getting this error locally whereas a few months ago I was not. Every time the session is restarted I get it.

craigh commented 10 years ago

I see this error also when doing a composer update

Compiling component files PHP Notice: Undefined index: __request in /home/ntq/public_html/core/src/lib/legacy/Zikula/ServiceManager.php on line 114 Clearing the cache for the dev environment with debug true PHP Notice: Undefined index: __request in /home/ntq/public_html/core/src/lib/legacy/Zikula/ServiceManager.php on line 114 Installing assets using the hard copy option

craigh commented 10 years ago

there is some similar code already here: https://github.com/zikula/core/blob/1.4/src/lib/legacy/Zikula/Core.php#L406

craigh commented 10 years ago

for the record, here is the full trace:

in /Applications/MAMP/htdocs/core.git/src/lib/legacy/Zikula/ServiceManager.php line 114
at ErrorHandler->handle('8', 'Undefined index: __request', '/Applications/MAMP/htdocs/core.git/src/lib/legacy/Zikula/ServiceManager.php', '114', array('id' => 'request', 'invalidBehavior' => '2')) in /Applications/MAMP/htdocs/core.git/src/lib/legacy/Zikula/ServiceManager.php line 114
at Zikula_ServiceManager->get('request', '2') in /Applications/MAMP/htdocs/core.git/src/app/cache/dev/appDevDebugProjectContainer.php line 434
at appDevDebugProjectContainer->getCmfRouting_DynamicRouterService() in /Applications/MAMP/htdocs/core.git/src/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php line 312
at Container->get('cmf_routing.dynamic_router', '1') in /Applications/MAMP/htdocs/core.git/src/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php line 464
at ContainerBuilder->get('cmf_routing.dynamic_router', '1') in /Applications/MAMP/htdocs/core.git/src/lib/legacy/Zikula/ServiceManager.php line 117
at Zikula_ServiceManager->get('cmf_routing.dynamic_router') in /Applications/MAMP/htdocs/core.git/src/app/cache/dev/appDevDebugProjectContainer.php line 534
at appDevDebugProjectContainer->getCmfRouting_RouterService() in /Applications/MAMP/htdocs/core.git/src/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php line 312
at Container->get('cmf_routing.router', '1') in /Applications/MAMP/htdocs/core.git/src/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php line 464
at ContainerBuilder->get('cmf_routing.router', '1') in /Applications/MAMP/htdocs/core.git/src/lib/legacy/Zikula/ServiceManager.php line 117
at Zikula_ServiceManager->get('cmf_routing.router') in /Applications/MAMP/htdocs/core.git/src/app/cache/dev/appDevDebugProjectContainer.php line 419
at appDevDebugProjectContainer->getCacheWarmerService() in /Applications/MAMP/htdocs/core.git/src/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php line 312
at Container->get('cache_warmer', '1') in /Applications/MAMP/htdocs/core.git/src/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php line 464
at ContainerBuilder->get('cache_warmer', '1') in /Applications/MAMP/htdocs/core.git/src/lib/legacy/Zikula/ServiceManager.php line 117
at Zikula_ServiceManager->get('cache_warmer') in /Applications/MAMP/htdocs/core.git/src/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php line 571
at Kernel->initializeContainer() in /Applications/MAMP/htdocs/core.git/src/lib/Zikula/Bundle/CoreBundle/HttpKernel/ZikulaKernel.php line 299
at ZikulaKernel->initializeContainer() in /Applications/MAMP/htdocs/core.git/src/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php line 128
at Kernel->boot() in /Applications/MAMP/htdocs/core.git/src/lib/Zikula/Bundle/CoreBundle/HttpKernel/ZikulaKernel.php line 86
at ZikulaKernel->boot() in /Applications/MAMP/htdocs/core.git/src/lib/bootstrap.php line 33
at include('/Applications/MAMP/htdocs/core.git/src/lib/bootstrap.php') in /Applications/MAMP/htdocs/core.git/src/index.php line 16
phaidon commented 10 years ago

I have this error too.

The installer does not work anymore, because of this.

cmfcmf commented 10 years ago

The error will be gone once my Routing PR is finished. For now you can use the workaround mentioned above.

craigh commented 10 years ago

The installer may have completed successfully but leaves this error at the end?

phaidon commented 10 years ago

@cmfcmf the work around helps, but now I get

ORMInvalidArgumentException: EntityManager#persist() expects parameter 1 to be an entity object, NULL given. in Zikula/src/vendor/doctrine/orm/lib/Doctrine/ORM/ORMInvalidArgumentException.php line 169

but maybe this is another problem.

cmfcmf commented 10 years ago

That's something different.

Guite commented 10 years ago

Fixed in 3eaa542888d59677691e6617856e4e42afc07da8