symfony/symfony — Issue #2964: Inlining property-injected service definitions generates invalid XML
Author: mirsal
Created: 2011-12-26 16:54:35+00:00
State: open

Hello,

Defining a private service then injecting it only once will cause its definition to be dumped 'inline' when generating the cached service definitions XML file (which is expected). However, when this service is injected using property injection, the following error occurs:

[InvalidArgumentException]

[ERROR 1871] Element '{http://symfony.com/schema/dic/services}service':
This element is not expected. (in [...] /app/cache/dev/appDevDebugProjectContainer.xml [...] )

The cached services definitions XML files contains the following chunk, which is indeed invalid:

[...]

You can reproduce the issue by adding the following snippet in a services definitions XML file:

Temporary workaround: Make that service definition public so it does not get inlined.

When it comes to a permanent fix, I am not sure about whether the xsd should accept inlined definitions of property-injected services (see: https://groups.google.com/group/symfony-devs/browse_thread/thread/d4ad8626db8316c3 for a somewhat related issue) or if property-injected services should just skip inlining.

All the best,

--
mirsal