CachedCiviContainer generated with Symfony 4 removes private services
When using Symfony 4.4, private services & aliases are removed from the generated
CachedCiviContainer.*.php file making them missing/unavailable.
- Set up a Drupal 9 site using composer (requires
symfony/dependency-injectionand other Symfony packages with version ^4.4). (I know Drupal 9 isn't officially supported yet, but civicrm-core does claim it can use Symfony ~3.0 || ~4.4 and I think Symfony is the problem here)
- Follow instructions from "Install CiviCRM on Drupal 8" documentation to add/install CiviCRM.
- If you look at the
CachedCiviContainer.*.phpfile generated in the
templates_cfolder, you can see
$this->aliasesare empty arrays, whereas with Symfony 3 there was a 'cache.short' alias and a number of private services that are now missing.
.../civicrm/admin/extensions?reset=1page and it will break.
The "cache.short" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.
There are probably other pages/actions that try & fail to use one of the services/alias that were removed, but this is the one I found.
Page should load without error!
- CiviCRM: 5.29.0
- PHP: 7.3
- CMS: Drupal 9.0.5
- Database: MariaDB 10.4
- Web Server: Nginx
I believe Symfony 4 may remove these private services/alias with
RemoveUnusedDefinitionsPass because they look "unused"? The error message offers a solution, make these services/alias public or "stop using the container directly and use dependency injection instead". I'm not sure what the implications of making them public are, or how much work would be involved in using dependency injection.